如何删除添加了.css()函数的样式? [英] How can I remove a style added with .css() function?

查看:100
本文介绍了如何删除添加了.css()函数的样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery更改CSS,我希望根据输入值删除我添加的样式:

I'm changing CSS with jQuery and I wish to remove the styling I'm adding based on the input value:

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).

第二个注意:我做不到这与 css(background-color,none)因为它将从css文件中删除默认样式。我只想删除jQuery添加的 background-color 内联样式。

2nd note: I can't do this with css("background-color", "none") because it will remove the default styling from the css files. I just want to remove the background-color inline style added by jQuery.

推荐答案

将属性更改为空字符串似乎可以完成工作。

Changing the property to an empty string appears to do the job.

$。css(background-color,) ;

这篇关于如何删除添加了.css()函数的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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