'TextRange' Example : TextRange « Javascript Objects « JavaScript DHTML






'TextRange' Example

    
<html>
<head>
<script language="javascript">
function displayText(){
    textRange = document.all.myBody.createTextRange();
    textRange.moveToElementText(myP);
    var m = textRange.text;
    alert(m); 
} 
</script>
</head>

<body id="myBody">
<p id="myP">This is some text in the document inside a p element</p>
<button onclick="displayText();">Display the text range</button>
</body>

</html>

    
      
      








Related examples in the same category