jQuery - 删除添加了.css()函数的样式 [英] jQuery - remove style added with .css() function

查看:112
本文介绍了jQuery - 删除添加了.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,) ;

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

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