国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

javascript搜索框效果實現方法

2019-11-20 12:29:08
字體:
來源:轉載
供稿:網友

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

<!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 == "請輸入關鍵字" || this.value == "") {      this.value = "";      this.style.color = "black"; //修改文本框字體顏色    }  }  txtSearch.onblur = function () {    if (this.value == "請輸入關鍵字" || this.value == "") {      this.value = "請輸入關鍵字";      this.style.color = "red";  //修改文本框字體顏色    }    else {      this.style.color = "black";    }  }}</script></head><body onload="iniEvent()"><!--文字離開如果文本框為空則顯示紅色的"請輸入關鍵字"--><!--<label for="txtSearch">查找</label><input type="text" id="txtSearch" value="請輸入關鍵字" style="color:red" />-->查找<input type="text" id="txtSearch" value="請輸入關鍵字" style="color:red" /><br /><input type="text" /></body></html>

希望本文所述對大家的javascript程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 金山区| 广东省| 麻阳| 盐池县| 连州市| 汽车| 宁城县| 广灵县| 金门县| 宁晋县| 安顺市| 启东市| 黑水县| 特克斯县| 杂多县| 普宁市| 嵊州市| 六安市| 色达县| 青岛市| 东阳市| 大港区| 拜泉县| 科尔| 靖边县| 新泰市| 河津市| 陵川县| 比如县| 武安市| 乐至县| 阜平县| 肥西县| 三亚市| 黔西| 肃宁县| 乡城县| 内丘县| 常山县| 海丰县| 玉田县|