问题:
I'm changing CSS with jQuery and I wish to remove the styling I'm adding based on the input value: 我正在用jQuery更改CSS,我但愿根据输入值删除我添加的样式: css
if(color != '000000') $("body").css("background-color", color); else // remove style ?
How can I do this? 我怎样才能作到这一点? Note that the line above runs whenever a color is selected using a color picker (ie. when mouse moves over a color wheel). 请注意,只要使用颜色选择器选择颜色(即鼠标在色轮上移动时),就会运行上面的一行。 函数
2nd note: I can't do this with css("background-color", "none")
because it will remove the default styling from the css files. 第二个注意事项:我没法用css("background-color", "none")
执行此操做,由于它将从css文件中删除默认样式。 I just want to remove the background-color
inline style added by jQuery. 我只想删除jQuery添加的background-color
内联样式。 this
解决方案:
参考一: https://stackoom.com/question/GwAb/如何删除添加了-css-函数的样式参考二: https://oldbug.net/q/GwAb/How-can-I-remove-a-style-added-with-css-function