0

I know the following JQuery will remove an attribute from an image tag

$('img').removeAttr('height');

in

<img src="images/abc.jpg" alt="Image 1" height="30px" width="30px" />

But how can I do the same if the img tag in in the following format?

<img src="images/abc.jpg" alt="Image 1" style="height:30px; width:30px;" />

Also how to do the same if the CSS in in an external file

<img src="images/abc.jpg" alt="Image 1" class="imgclass1" />
1

1 Answer 1

1

If you do

$('img').css('height', '');

jQuery will remove the height style from the element

removes that property from an element if it has already been directly applied, whether in the HTML style attribute

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.