Move to element text in a text range : Text Range : DOM Node JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » DOM Node » Text Range »

 

Move to element text in a text range

















This example uses Internet Explorer ranges and will only work on Internet Explorer
<html>
    <head>
        <title>IE Range Example</title>
        <script type="text/javascript">
            function useRanges() {
                var oRange = document.body.createTextRange();
                var oP1 = document.getElementById("p1");
                oRange.moveToElementText(oP1);
                alert(oRange.htmlText);
            }
        </script>
    </head>
    <body><p id="p1"><b>Hello</b> World</p>
        <input type="button" value="Use Ranges" onclick="useRanges()" />   
    </body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo DOM Node
» Text Range