<html> <body> <script language="JavaScript"> function function1() { var myControlR = document.body.createControlRange(); myControlR.add(myT); var m = myControlR.length; alert("There are "+ m +" elements in the controlRange collection") } </script> <input id="myT" type="button" value="Click me" onclick="function1();"> </body> </html>