Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

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

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

(我正在用jQuery更改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内联样式。)

  ask by Alex translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

将属性更改为空字符串似乎可以完成以下任务:

$.css("background-color", "");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...