[JavaScript] JS代码选择TextArea内的文本 →→→→→进入此内容的聊天室

来自 , 2021-02-27, 写在 JavaScript, 查看 103 次.
URL http://www.code666.cn/view/27d52bcb
  1. <!------>
  2.  
  3. <script type="text/javascript">
  4.  
  5.     function select_field(id){
  6.  
  7.         document.getElementById(id).focus();
  8.         document.getElementById(id).select();
  9.  
  10.     }
  11.  
  12.     function init(){
  13.         select_field('text1');
  14.     }
  15.  
  16.     onload=init;
  17.  
  18. </script>
  19.  
  20. <form>
  21.  
  22. This field gets selected onload:<br/>
  23. <input type="text" name="text1" id="text1" value="some text" />
  24.  
  25. <br/>
  26.  
  27. <textarea name="textarea1" id="textarea1" rows="9" cols="50" wrap="off">Some long
  28. content in here.
  29. abcd efgh abcd efgh abcd efgh
  30. abcd efgh abcd efgh abcd efgh
  31. abcd efgh abcd efgh abcd efgh
  32. </textarea>
  33.  
  34. <br/>
  35.  
  36. <input type="button" value="Select text" onclick="select_field('textarea1')">
  37.  
  38. </form>
  39. //javascript/2070

回复 "JS代码选择TextArea内的文本"

这儿你可以回复上面这条便签


//javascript/2070
captcha