类似input框内最右边添加图标,有清空功能
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<!-- js引入 -->
<script type="text/javascript" src="../js/jquery-1.10.2.js" ></script>
<link href="bootstrap.css" rel="stylesheet">
<style type="text/css">
.round { /*大span*/
background: #fff none repeat scroll ;
border: 1px solid #bbb;
display: inline-block;
height: 28px;
margin-right: 2px;
vertical-align: top;
width: 175px;
position: relative;
}
.delquery { /*清除图标*/
background-position: -320px;
cursor: pointer;
height: 20px;
margin: 4px 0px ;
position: absolute;
right: ;
top: ;
width: 20px;
}
.input_key { /*input框*/
background: #fff none repeat scroll ;
border: none;
border-radius: ;
font: 16px/22px arial;
height: 18px;
margin: 5px 5px;
outline: none;
padding: ;
width: 140px;
background-repeat: no-repeat;
}
</style>
</head>
<body>
<h1>监听_input值的变化</h1>
<table>
<tr>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td>
<span class="round" id="suggest-align">
<input type=" name="q" id="keyword">
<span title="清空" class="delquery" id="clear" style="display: none;">x</span>
</span>
</td>
</tr>
</table>
</body>
<script type="text/javascript">
$(function(){
$("#clear").click(function(){
$(".input_key").val("");
$(".input_key").focus();
$(this).hide();
})
/* var tValue;
setInterval(function(){
if(tValue !=$("#keyword").val()){ //这里写自己的业务逻辑代码
if ($(".input_key").val().trim()!="") {
$("#clear").show();
}
tValue =$("#keyword").val();
}
},100); */
var tValue;
$("#keyword").keydown(function(){
if ($(".input_key").val().trim()!="") {
$("#clear").show();
}
});
$("#keyword").keyup(function(){
if ($(".input_key").val().trim()!="") {
$("#clear").show();
}
});
})
</script>
</html>
类似input框内最右边添加图标,有清空功能的更多相关文章
- input框内默认文字点击消失
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- input框内的单引号,双引号转译
主要是在后台传前端之前先把变量值替换单引号双引号成转译付. $bianlian是要替换的变量 两种方法 1.php后台输出值先转译 //双引号替换成转译符 $bianlian=preg_replace ...
- zTree重命名节点时,操作的那个dom(类似input框那个)怎么写
<script type="text/javascript"> //tree的编辑节点的方法 ztree.editName(nodeNew[0]); /// $(&qu ...
- 在 input 上添加图标字体时无法添加的问题
效果:一个搜索框.如图: 实施过程:一开始,将搜索框分为2部分,用2个 input ,一个 search ,一个 button ,然后给 type="button" 的input ...
- h5 页面点击添加添加input框
h5 页面点击添加添加input框 前段时间有个需求,页面要能点击添加按钮控制input框的个数,当时感觉有点难,就没做,这两个又遇到了,没办法写了个简单的 效果图,加号增加,减号减少 直接上代码, ...
- bootstrap的两种在input框里面增加一个图标的方式
具体代码如下: <div class="input-group"> <div class="input-icon-group"> < ...
- bootstrap在input框中加入icon图标
<form class="form-horizontal"> <div class="form-group has-feedback"> ...
- 让单选input框,不在被选中,添加disabled即可。输入框input的一些技巧
1.让单选input框,不在被选中,添加disabled即可 2.input的file文件对象的清空,只需要input.val("");就可以了.
- SharePoint 2010 类似人人网站内信功能实施
简介:用SharePoint代码加实施的方式,完成类似人人网站内信功能,当然,实现的比较简单,样式也比较难看,只为给大家一个实施的简单思路,如有谬误,还请见谅.当然,还有就是截图比较长,当然为了让大家 ...
随机推荐
- Sql Server 常用系统存储过程大全
-- 来源于网络 -- 更详细的介结参考联机帮助文档 xp_cmdshell --*执行DOS各种命令,结果以文本行返回. xp_fixeddrives --*查询各磁盘/分区可用空间 xp_logi ...
- 【spring bean】 spring中bean之间的引用以及内部bean
在spring中会有如下的几种情况: 1.在当前容器中,(即在spring.xml这一个配置文件中),一个bean引用了另一个bean. 使用 1> <ref bean="另 ...
- loadrunner通过字符串左右边界切割字符串
void web_reg_save_param_custom(char *sourceStr, char* outpuStr, char *leftBdry, char *rightBdry){ ...
- asp.net权限控制配置web.config
项目下 有三个文件夹 A,B,C 验正方式是 Forms 验正 我要设置他们的访问权限为, A,匿名可访问 B,普通用户授权后才能访问 C,只允许管理员访问 <configuration> ...
- css 让内容满屏居中不变形
.selector { position: fixed; width: 100%; height: 100%; background-image: url(path); background-repe ...
- 从Sql server 2008获取表字段属性信息,注释信息
select b.[value] from sys.columns a left join sys.extended_properties b on a.object_id=b.major_id ...
- apache htpasswd.exe创建密码
一.使用apache htpasswd.exe创建密码文件,命令请看PHP推荐教程:apache htpasswd命令用法详解 apache htpasswd命令用法实例 1.如何利用htpasswd ...
- HDU 2586 (LCA模板题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2586 题目大意:在一个无向树上,求一条链权和. 解题思路: 0 | 1 / \ 2 3 ...
- BZOJ1858[Scoi2010]序列操作 题解
题目大意: 有一个01序列,现在对于这个序列有五种变换操作和询问操作: 0 a b 把[a, b]区间内的所有数全变成0:1 a b 把[a, b]区间内的所有数全变成1:2 a b 把[a,b]区间 ...
- ACM: 限时训练题解-Rock-Paper-Scissors-前缀和
Rock-Paper-Scissors Rock-Paper-Scissors is a two-player game, where each player chooses one of Roc ...