admin管理员组文章数量:1290105
I have inline style
<div class="handle" id="parent4" value="3" size="large" style="position: relative; top: 0px; left: 0px; z-index: 0; cursor: pointer;"></div>
i want remove the position relative style in tha above code using jquery
<div class="handle" id="parent4" value="3" size="large" style= top: 0px; left: 0px; z-index: 0; cursor: pointer;"></div>
I have inline style
<div class="handle" id="parent4" value="3" size="large" style="position: relative; top: 0px; left: 0px; z-index: 0; cursor: pointer;"></div>
i want remove the position relative style in tha above code using jquery
<div class="handle" id="parent4" value="3" size="large" style= top: 0px; left: 0px; z-index: 0; cursor: pointer;"></div>
Share
Improve this question
edited Jun 18, 2014 at 12:16
Sudharsan S
asked Apr 17, 2014 at 8:33
Sudharsan SSudharsan S
15.4k4 gold badges34 silver badges51 bronze badges
4 Answers
Reset to default 4Try to override the position with static
,
$('#parent4').css('position','static');
since static
is the default position for any div elements.
For removing style, you can use .css(stylename,'')
syntax.So in your case use this:
$('#parent4').css('position','');
Set the position to static, that's the default value.
Here is the code to remove
(function($)
{
$.fn.removeStyle = function(style)
{
var search = new RegExp(style + '[^;]+;?', 'g');
return this.each(function()
{
$(this).attr('style', function(i, style)
{
return style.replace(search, '');
});
});
};
}(jQuery));
Using this mini plugin you can write in your JS file
$('#element').removeStyle('position');
本文标签: javascriptremove only position relative inline style using jqueryStack Overflow
版权声明:本文标题:javascript - remove only position relative inline style using jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741490310a2381587.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论