How to remove style property

Possible Duplicate:
jQuery - remove style added with .css() function

I want to remove the style property from the div , i cannot use the removeAttribute and removeProperty as removeAttribute removes whole style and remove Property doesnot works in ie. Is there any other way to do it.

<div style="visiblity:hidden;margin-right:10px;margin-left:10px">

I want to remove only visibility style property.


Use the .css as such

$(elementSelect).css('marginRight', null);

or

$(elementSelect).css('marginRight', '0px').css('visibility', 'visible');

Do you mean:

<div id="testDiv" style="visiblity:hidden;margin-right:10px;margin-left:10px">Here</div>

$('#testDiv').attr('style', function(i, style) {
    return style.replace(/visiblity[^;]+;?/g, '');
});

Example: jsFiddle


你可以试试这个:

$('div').css('visibility', '')
链接地址: http://www.djcxy.com/p/94870.html

上一篇: 在CSS和Jquery中将颜色更改回默认值

下一篇: 如何删除样式属性