views:

32

answers:

2

I mean, assume a web page is very long and contain lots of words, now i just want to get the value of a textnode which is being shown on the screen.How could i do it? Thanks! :)

what's more: I mean, i know how to get the value of a textnode,but if a web page is very lage and contains thousands of words, what i want to do is that,only get the shown textnode of the dom tree.That means if you slither a mouse wheel,some text disappear and some come into your vision.

A: 

var item = document.getElementById('elementId'); alert(item.value);

A: 

See the textContent (DOM) and innerText (IE) properties.

Or, in jQuery, use $(elem).text();

janmoesen