最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS實(shí)現(xiàn)搜索框文字可刪除功能

 更新時(shí)間:2016年12月28日 10:58:58   作者:舊顏_  
本文給大家分享一段js代碼實(shí)現(xiàn)搜索框文字可刪除功能,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧

廢話不多說了,直接給大家貼js搜索框文字可刪除功能,具體代碼如下所示:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS實(shí)現(xiàn)搜索框文字可刪除</title>
<style>
*:focus {outline: none; }
body {width: 400px;margin: 100px auto;}
#topsearch {height: 33px;}
#topsearch .input {border: 1px solid #77c03a;height: 100%;}
#topsearch .input .clear {width: 30px;height: 35px;line-height: 30px;text-align: center;padding-right: 10px;visibility: hidden;opacity: 0.8;color: gray;}
#topsearch input[type=text] {height:20px;width: 250px;border: none;padding: 5px;}
#topsearch div {float: left;}
#topsearch button {width: 100px;height: 35px;background: #77c03a;color: #fff;border: none;}
</style>
</head>
<body>
<div id="topsearch">
<div class="input"><input type="text" id="search"><span class="clear" id="delete">×</span></div>
<button type="button" name="searchz">Search</button>
</div>
<script>
document.getElementById("search").addEventListener("keyup", function() {
if (this.value.length > 0) {
document.getElementById("delete").style.visibility = "visible";
document.getElementById("delete").onclick = function() {
document.getElementById("search").value = "";
}
} else {
document.getElementById("delete").style.visibility = "hidden";
}
});
</script>
</body>
</html>

相關(guān)文章

最新評(píng)論

开江县| 太仆寺旗| 滨海县| 嘉兴市| 延安市| 西丰县| 阳新县| 旌德县| 辽中县| 卢氏县| 昭觉县| 庆元县| 佛山市| 乐业县| 聊城市| 镇康县| 蒙山县| 宁明县| 绥中县| 湖北省| 宣城市| 科技| 太保市| 乌拉特中旗| 铜陵市| 昌乐县| 黄陵县| 客服| 遂宁市| 汉阴县| 浪卡子县| 博白县| 武强县| 海原县| 隆回县| 余姚市| 九龙城区| 城市| 灵寿县| 泸溪县| 清涧县|