开发者

stop automatical convert to htmlentities?

I have a div id="ultimativegodemperorofalldivs" It contains some Text like "such a cool & sexy div"

when I extract the InnerHTML with JS it converts the & to & I really don't want this. I don't need it for URL's so it really should be a very si开发者_运维技巧mple &. How to archive this?

Thx in Advance, iceteea


Like its name says, innerHTML retrieves the element’s inner HTML. Without HTML entities, it wouldn’t be valid HTML. If you want to retrieve the element’s text content, you’ll have to use the element’s textContent or innerText properties.

(innerText is only supported in IE; but textContent is not supported by older versions of IE).


Instead of using innerHTML.you can use innerText

document.getElementById('ultimativegodemperorofalldivs').innerText

Hope this helps!!!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜