이 기사에서는 JS가 입력 상자를 제어하여 초점을 얻고 잃어버린 상태에서 상태를 표시하는 방법에 대해 설명합니다. 참조를 위해 공유하십시오. 특정 구현 방법은 다음과 같습니다.
<! 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 = gb2312"/> <title> 테두리 색상 변경 </title> <text/css "> -search Keyword {. #797a75; 너비 : 202px; 색상 : #cdcdcd; font-size : 12px;} .SearchkeyWordonFocus {border : 1px solid #abcd3a; width : 202px; color : #00000; font-size;}-> 스타일> <script language = "javascus". (document.formsearch.keyword.value == '키워드를 입력하십시오') {document.formsearch.keyword.value = ''; document.formsearch.keyword.classname = 'SearchKeywordonFocus'; }} function keywordBlur () {if (document.formsearch.keyword.value == '') {document.formsearch.keyword.value = '키워드를 입력하십시오'; document.formsearch.keyword.className = 'searchKeyword'; }} </script> </head> <body> <form id = "formsearch"name = "formsearch"method = "post"action = ""> <입력 유형 = "text"name = "keyword"value = "keyword"onfocus = "keywordfocus ();" onblur = "keywordblur ();" /> </form> </body> </html>이 기사가 모든 사람의 JavaScript 프로그래밍에 도움이되기를 바랍니다.