Clear the text style of the Element using Javascript
I need to clear the text decoration property of the element using j开发者_运维问答ava script.
Currently I am setting text decoration property of element to 'line-through'. In some point of time i need to undo the strike process.
How to reset the text decoration property using javascript?
Here's one way:
HTML
<p id="a">Some text</p>
CSS
p{text-decoration:line-through;}
js
var p = document.getElementById('a')
p.style.textDecoration = 'none';
http://jsfiddle.net/jasongennaro/nVeGB/
Javascript: document.getElementById(element_id).style.textDecoration = "none"
jQuery: $('#element_id').css("text-decoration", "none");
setting text-decoration to none actually is a bit worser then setting text-decoration to "". $("div").css("text-decoration", "")
The difference is that by setting to empty string you actually removing js-setted property.
Say, you element has text-decoration: "underline"
initially (in css, before you've set the value using jQuery). Setting it to "none" will be wrong. Removing the property will be nice.
set the text decoration to none
or with
document.getElementById(divID).style.removeAttribute("textDecoration",false)
you can remove the textDecoration form the style (works in IE )
精彩评论