欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript搜索框效果實(shí)現(xiàn)方法

 更新時(shí)間:2015年05月14日 09:54:24   作者:永遠(yuǎn)愛好寫程序  
這篇文章主要介紹了javascript搜索框效果實(shí)現(xiàn)方法,可實(shí)現(xiàn)顯示默認(rèn)提示文字的搜索框效果,非常簡單實(shí)用,需要的朋友可以參考下

本文實(shí)例講述了javascript搜索框效果實(shí)現(xiàn)方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

<!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>搜索框效果</title>
<script type="text/javascript">
function iniEvent() {
  var txtSearch = document.getElementById("txtSearch");
  txtSearch.onfocus = function () {
    if (this.value == "請輸入關(guān)鍵字" || this.value == "") {
      this.value = "";
      this.style.color = "black"; //修改文本框字體顏色
    }
  }
  txtSearch.onblur = function () {
    if (this.value == "請輸入關(guān)鍵字" || this.value == "") {
      this.value = "請輸入關(guān)鍵字";
      this.style.color = "red";  //修改文本框字體顏色
    }
    else {
      this.style.color = "black";
    }
  }
}
</script>
</head>
<body onload="iniEvent()">
<!--文字離開如果文本框?yàn)榭談t顯示紅色的"請輸入關(guān)鍵字"-->
<!--<label for="txtSearch">查找</label>
<input type="text" id="txtSearch" value="請輸入關(guān)鍵字" 
style="color:red" />-->
查找<input type="text" id="txtSearch" value="請輸入關(guān)鍵字" 
style="color:red" /><br /><input type="text" />
</body>
</html>

希望本文所述對大家的javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 使用SVG基本操作API的實(shí)例講解

    使用SVG基本操作API的實(shí)例講解

    下面小編就為大家?guī)硪黄褂肧VG基本操作API的實(shí)例講解。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-09-09
  • js 動(dòng)態(tài)修改css文件的方法

    js 動(dòng)態(tài)修改css文件的方法

    css文件可以用js 動(dòng)態(tài)修改,在做一些交互動(dòng)作時(shí),非常實(shí)用,下面是具體示例,大家可以看看
    2014-08-08
  • JS中產(chǎn)生標(biāo)識符方式的演變

    JS中產(chǎn)生標(biāo)識符方式的演變

    本文記錄下JS中產(chǎn)生標(biāo)識符方式的演變,從ES5到ES6,ES5及其之前是一種方式,只包含兩種聲明(var/function),ES6則增加了一些產(chǎn)生標(biāo)識符的關(guān)鍵字,如 let、const、class。
    2015-06-06
  • 最新評論