Cet article décrit la méthode d'affichage de l'état lorsque JS contrôle la zone d'entrée pour obtenir et perdre la mise au point. Partagez-le pour votre référence. La méthode de mise en œuvre spécifique est la suivante:
<! 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"> <éadf> <méta http-equiv = "contenu-type" contenu = "text / html; charset = gb2312" /> <itle> border couleur change </ title> <style type = "text / css"> <! -. # 797A75; largeur: 202px; couleur: #cdcdcd; font-taille: 12px;} .searchkeywordonfocus {border: 1px solide # abcd3a; width: 202px; couleur: # 000000; font-size: 12px;} -> </ypie> <script lingngut = "javascrip" (document.formSearch.keyword.value == 'Veuillez entrer le mot-clé') {document.formSearch.keyword.value = ''; document.formSearch.keyword.classname = 'searchKeywordonfocus'; }} fonction keywordblur () {if (document.formSearch.keyword.value == '') {document.formSearch.keyword.value = 's'il vous plaît entrez le mot-clé'; document.formSearch.keyword.classname = 'searchKeyword'; }} </ Script> </ head> <body> <form id = "formSearch" name = "formSearch" metheth = "post" action = ""> <input type = "text" name = "keyword" value = "s'il vous plaît entrez le mot-clé" onfocus = "keywordfocus ();" onblur = "keywordblur ();" /> </ form> </ body> </html>J'espère que cet article sera utile à la programmation JavaScript de tous.