How to remove width attribute which is under style attribute using jQuery?
JqueryJquery 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;
}