Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove height and width?

currently I am working on an image slider with jquery. I have downloaded the code from the net. My code demo is here.

My question is: how can I remove the height and width attaching dynamically to image tag as inline style?

Thanks.

like image 846
rajeshrt Avatar asked Jan 27 '11 05:01

rajeshrt


2 Answers

Try to use this code:

$('your-image').css({ 
  width: '',
  height: ''
});

If you want to set the "original" image dimensions try this:

$('your-image').css({ 
  width: 'auto',
  height: 'auto'
});
like image 88
Olegas Avatar answered Sep 25 '22 07:09

Olegas


You can do it with vanilla JavaScript too.

let articleContentImages = document.getElementById("articleContent").getElementsByTagName("img");
for(let i = 0; i < articleContentImages.length; i++){
    articleContentImages[i].style.height = "auto";
    articleContentImages[i].style.width = "auto";
}
like image 21
Grant Avatar answered Sep 26 '22 07:09

Grant