栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何给input的右上角加个清除的按钮?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何给input的右上角加个清除的按钮?

<title>Insert title here</title><style type="text/css">

.round { /大span/
background: #fff none repeat scroll 0 0;
border: 1px solid #bbb;
display: inline-block;
height: 28px;
margin-right: 2px;
vertical-align: top;
width: 175px;
position: relative;
}
.delquery { /清除图标/
background-position: 0 -320px;
cursor: pointer;
height: 20px;
margin: 4px 0px 0 0;
position: absolute;
right: 0;
top: 0;
width: 20px;
}
.input_key { /input框/
background: #fff none repeat scroll 0 0;
border: 0 none;
border-radius: 0;
font: 16px/22px arial;
height: 18px;
margin: 5px 0 0 5px;
outline: 0 none;
padding: 0;
width: 140px;
background-repeat: no-repeat;
}
</style>

x<script src="./js/jquery.min.js"></script><script type="text/javascript">$(function(){$("#clear").click(function(){ $(".input_key").val(""); $(".input_key").focus(); $(this).hide();})$("#keyword").keydown(function(){ console.log($(".input_key").val()) if ($(".input_key").val().trim()!="") { $("#clear").show(); }});$("#keyword").keyup(function(){ if ($(".input_key").val().trim()!="") { $("#clear").show(); }});

})

</script>
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/669907.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号