javascript Programming Glossary: gettextnodesin
How do I select text nodes with jQuery? http://stackoverflow.com/questions/298750/how-do-i-select-text-nodes-with-jquery but no text nodes. Here's what I've come up with var getTextNodesIn function el return el .find not iframe .addBack .contents .filter.. .addBack .contents .filter function return this.nodeType 3 getTextNodesIn el Note If you're using jQuery 1.7 or earlier the code above.. in jQuery they are automatically filtered out . function getTextNodesIn node includeWhitespaceNodes var textNodes nonWhitespaceMatcher..
Highlight text range using JavaScript http://stackoverflow.com/questions/6240139/highlight-text-range-using-javascript jsfiddle.net 8mdX4 And the selection setting code function getTextNodesIn node var textNodes if node.nodeType 3 textNodes.push node else.. children.length i len i textNodes.push.apply textNodes getTextNodesIn children i return textNodes function setSelectionRange el start.. range.selectNodeContents el var textNodes getTextNodesIn el var foundStart false var charCount 0 endCharCount for var..
|