使用Jquery删除CSS属性 [英] Remove CSS attribute using Jquery

查看:115
本文介绍了使用Jquery删除CSS属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现的所有其他答案只是删除属性的设置,而不是完全删除属性。我把一个元素从绝对定位改为固定定位。我需要删除正确的定位属性,并将其替换为margin-right,使元素在其父DIV中位置正确。如果没有删除正确的属性,元素一直到屏幕的右侧,而不是在DIV的右边,就像我需要它。任何人都可以提出如何完成这个建议?

All of the other answers I have discovered only remove the setting of the attribute, and not the attribute completely. I am changing an element from absolute to fixed positioning. I need to remove the right positioning attribute and replace it with margin-right so that the element is position right within its parent DIV. If the right attribute is not removed, the element goes all the way to the right of the screen, and not to the right of the DIV like I need it to. Can anyone offer a suggestion on how to accomplish this?

推荐答案

尝试将其设置为默认值 auto

Try setting it to its default value auto

$(element).css('right', 'auto');

这篇关于使用Jquery删除CSS属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆