admin管理员组

文章数量:1431391

I use JavaScript to set the CSS text-shadow property. Here is my code to set the text-shadow property:

var text = document.getElementById("text");
text.style.textShadow = "1px 1px 0 red";

Once I set it, how do I unset the CSS text-shadow property using JavaScript? I tried

text.style.textShadow = "0 0 0 0";

but it does not work.

I use JavaScript to set the CSS text-shadow property. Here is my code to set the text-shadow property:

var text = document.getElementById("text");
text.style.textShadow = "1px 1px 0 red";

Once I set it, how do I unset the CSS text-shadow property using JavaScript? I tried

text.style.textShadow = "0 0 0 0";

but it does not work.

Share Improve this question edited Feb 26, 2016 at 22:22 gariepy 3,6846 gold badges23 silver badges34 bronze badges asked Dec 7, 2011 at 5:56 user774411user774411 1,8156 gold badges29 silver badges47 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4
text.style.textShadow = "none";

Or, depending on your needs:

text.style.textShadow = "inherit";

Try:

text.style.textShadow = "none";

In fact, playing around with this, setting it to "0 0", null, and "" all seem to work as well.

See working test: http://jsfiddle/YwPF9/

I think

text.style.textShadow = "0 0";

本文标签: How to unset CSS textshadow using JavaScriptStack Overflow