Artikel ini menjelaskan metode menampilkan status ketika JS mengontrol kotak input untuk mendapatkan dan kehilangan fokus. Bagikan untuk referensi Anda. Metode implementasi spesifik adalah sebagai berikut:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transisi // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <adept> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"/> <iteme> Perubahan warna perbatasan </title> <gaya type = "text/csss/csss." #797A75; Lebar: 202px; warna: #cdcdcd; font-size: 12px;} .searchKeywordOnfocus {border: 1px solid #abcd3a; width: 202px; color: #000000; font-size: 12px;}-> </style; (document.FormSearch.keyword.value == 'Harap masukkan kata kunci') {document.formsearch.keyword.value = ''; document.formsearch.keyword.classname = 'SearchKeywordOnfocus'; }} Function KeywordBlur () {if (document.FormSearch.keyword.value == '') {document.FormSearch.keyword.value = 'Harap masukkan kata kunci'; Document.FormSearch.keyword.className = 'SearchKeyWord'; }} </script> </head> <body> <Form id = "FormSearch" name = "FormSearch" Method = "POST" ACTION = ""> <input type = "text" name = "kata kunci" value = "Harap masukkan kata kunci" onfocus = "KeyWordFocus ();" Onblur = "KeyWordBlur ();" /> </form> </body> </html>Saya harap artikel ini akan membantu pemrograman JavaScript semua orang.