In diesem Artikel wird die Methode zum Anzeigen von Status beschrieben, wenn JS das Eingabefeld steuert, um den Fokus zu erhalten und zu verlieren. Teilen Sie es für Ihre Referenz. Die spezifische Implementierungsmethode lautet wie folgt:
<! DocType html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transsitional.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"/> <title> Border Color Change </title> <style tytyp: text "text:" text/cs #797a75; width: 202px; color: #cdcdcd; font-size: 12px;} .SearchKeywordonFocus {Border: 1px Solid #ABCD3A; Breite: 202px; color: #000000; font-size: 12px;}-> </styled = styLy> </styled = styled = " (document.formSearch.Keyword.Value == 'Bitte geben Sie das Schlüsselwort ein') {document.formSearch.Keyword.value = ''; document.formSearch.Keyword.classname = 'SearchKeywordonFocus'; }} function keywordblur () {if (document.formSearch.Keyword.value == '') {document.formSearch.Keyword.Value = 'Bitte geben Sie Keyword ein'; document.formSearch.Keyword.classname = 'SearchKeyword'; }} </Script> </head> <body> <form id = "formSearch" name = "filearch" methode = "post" action = ""> <input type = "text" name = "keyword" value = "Bitte geben Sie das Schlüsselwort" onfocus = "keywordFocus ();" onblur = "keywordBlur ();" /> </form> </body> </html>Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.