DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> JavaScript綜合知識 >> js實現文本框選中的方法
js實現文本框選中的方法
編輯:JavaScript綜合知識     

   本文實例講述了js實現文本框選中的方法。分享給大家供大家參考。具體如下:

  這段javascript代碼可解決文本框獲得焦點,即使得文本框的內容被選中。

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>select文件</title> <script language="javascript" type="text/javascript"> function getFocus() { document.getElementById("test").select(); } </script> </head> <body> <form id="f1"> <input type="text" id="test" name="test" value="你好嗎?" onfocus="getFocus();"/> </form> </body> </html>

  希望本文所述對大家的javascript程序設計有所幫助。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved