<! 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> search box effect </title> <Script type = "text/javascript"> Function iniEvent (){ Var txtSearch = document. getElementById ("txtSearch "); TxtSearch. onfocus = function (){ If (this. value = "Enter the keyword" | this. value = ""){ This. value = ""; This. style. color = "black"; // modify the font color of the text box. } } TxtSearch. onblur = function (){ If (this. value = "Enter the keyword" | this. value = ""){ This. value = "Enter keywords "; This. style. color = "red"; // modify the font color of the text box. } Else { This. style. color = "black "; } } } </Script> </Head> <Body onload = "iniEvent ()"> <! -- Text leaves. If the text box is empty, the red "enter a keyword" is displayed. --> <! -- <Label for = "txtSearch"> Search </label> <Input type = "text" id = "txtSearch" value = "enter a keyword" Style = "color: red"/> --> Search for <input type = "text" id = "txtSearch" value = "enter a keyword" Style = "color: red"/> <br/> <input type = "text"/> </Body> </Html> |