如何使用jQuery删除style属性下的width属性?
如何使用jQuery删除style属性下的width属性?
我知道removeAttr(“width”);
但是因为宽度是style属性的孩子所以在这里不起作用
你可以使用:
.css('width', 'auto')
一样容易
$('div.views').css('width', '');
这也适用于:
$(".views").width("");
不要使用内联样式。 使用类。
$(".views").removeClass("a"); $(".views").addClass("b");
但如果你真的想,你可以做以下事情:
$(".views").css("width", "");
你只能用CSS做到这一点:
div[style="position: absolute; top: -136px; overflow: auto; width:1241px;"] { width: 0px !important; display: none !important;
}
我想你必须试试这个:
$(".views").removeAttr('style').attr('style','position: relative; height: 15px; overflow: hidden;');
接受答案的略短版本:
.width('auto')