开发者

W3C Dom API get text content

开发者 https://www.devze.com 2022-12-11 19:52 出处:网络
according to http://www.w开发者_C百科3schools.com/dom/dom_node.asp, to get the text content of a node,

according to http://www.w开发者_C百科3schools.com/dom/dom_node.asp, to get the text content of a node, textContent for FF and text for IE, but leaves opera out, is there a cross platform way of getting the inner text content of a node?


The property that's most generic is the nodeValue property defined here:

http://www.w3schools.com/DOM/prop_document_nodevalue.asp

There is also a property called innerText that I beleive works in IE6.

The best option is to do some kind of object detection to ensure that the property you want to use, is available in the browser you're currently using.

Alternatively, a Javascript framework such as jQuery, YUI, ExtJS will provide you with methods that are already setup to be cross browser compatable.

0

精彩评论

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

关注公众号