How to remove width attribute which is under style attribute using jQuery?

Jquery

Jquery Problem Overview


<div class="views" style="position: relative; width: 421px; height: 15px; overflow: hidden;">
TEST TEXT
</div>

How to remove width attribute which is under style attribute using jQuery?

I know removeAttr("width");

But it will not work here because width is child of style attribute

Jquery Solutions


Solution 1 - Jquery

You could use:

.css('width', 'auto')

Solution 2 - Jquery

As easy as

$('div.views').css('width', '');

Solution 3 - Jquery

This also worked here:

$(".views").width("");

Solution 4 - Jquery

Don't use inline styles. Use classes.

$(".views").removeClass("a");
$(".views").addClass("b");

But if you really want to, you could do the following:

$(".views").css("width", "");

Solution 5 - Jquery

A slightly-shorter version of the accepted answer:

.width('auto')

Solution 6 - Jquery

I think you must try this:

$(".views").removeAttr('style').attr('style','position: relative; height: 15px; overflow: hidden;');

Solution 7 - Jquery

You can do that with CSS only:

div[style="position: absolute; top: -136px; overflow: auto; width:1241px;"] {
width: 0px !important;
display: none !important;

}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFeroView Question on Stackoverflow
Solution 1 - JqueryAvaqView Answer on Stackoverflow
Solution 2 - JqueryYuri GhensevView Answer on Stackoverflow
Solution 3 - JquerywarvariucView Answer on Stackoverflow
Solution 4 - JqueryjrummellView Answer on Stackoverflow
Solution 5 - JqueryNathan ArthurView Answer on Stackoverflow
Solution 6 - JqueryAkshay KhandelwalView Answer on Stackoverflow
Solution 7 - JqueryJovica ŠalovićView Answer on Stackoverflow