`

IE下选择文本框

阅读更多
<html>
   <head>
     <title>a test for selection object</title>
   </head>
   <body>
     <script language='javascript'>
       function selectionContentByScript() 
       { 
         var t=document.getElementById("test");   
         var o=t.createTextRange();     
             //o.moveStart("character",2);      
             o.select();    
       } 
     </script>
     <form>
       <input id='test' type='text' value='will be selected' />
       <br />
       <input type='button' onclick='javascript:selectionContentByScript();' value='select the text box value' />
     </form>
   </body>
</html>   
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics