juqery实现:原来的焦点在一个文本框上面,点击一个按钮得到失去焦点的文本框的值???????? juqery实现:原来的焦点在一个文本框上面,点击一个按钮得到失去焦点的文本框的值???????? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 文本框的失去焦点和点击一个按钮获得焦点的时间先后不确定,所以在点击按钮的时候判断是否能取到某个值,如果取不到,就一直取,知道取到为止js如下:假设文本框id为txt,按钮id为btnvar t_id="";//文本框id$("#txt").blur(function(e){t_id=this.id;})$("#btn").click(function(e){getIdEx();})function getIdEx(){if(t_id!="") {alert('获取的文本框的值为'+$("#"+t_id).val());t_id="";//这里获取到以后要重置为空}else setTimeout(getIdEx,200);)} 这个应该简单的: var getval=""; function getVals(){ $('#inputId').blur(function() { getval= $(this).val(); });这样写,两种方法 :1、赋予一个全局变量。2、写一个<input type="hidden" />离开焦点时候,赋予这个<input type="type"> 然后就可以搞定了。 <!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> <title></title> <style> * { margin: 0px; } </style> <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function($) { var sss; $("input:text").blur(function(event) { sss = $(this).val(); }); $("#Button1").click(function(event) { alert(sss); }); }); </script></head><body> <input id="Text1" type="text" /> <input id="Text2" type="text" /> <input id="Text3" type="text" /> <input id="Button1" type="button" value="button" /></body></html> jsp页面使用FCK编辑编写内容,保存到数据库为什么带样式? 问一下<script id=datasearch></script>是什么意思? 如何用 js把以\u开头的字符转换成原文? 截网站图片,生成图片后保存到本机可以实现吗? JS 动态创建form对象 请问,如何获得首页的地址? uncaught exception: [Exception... "Out of Memory" nsresult: "0x8007000e 关于层的拖动范围问题 如何用JS限制cookies24小时内的提交次数呢 求教~~ input标签获取焦点时文本框内提示信息清空 火狐怎么实现 层失去焦点后关闭
js如下:假设文本框id为txt,按钮id为btn
var t_id="";//文本框id
$("#txt").blur(function(e){t_id=this.id;})
$("#btn").click(function(e){getIdEx();})
function getIdEx()
{
if(t_id!="")
{
alert('获取的文本框的值为'+$("#"+t_id).val());
t_id="";//这里获取到以后要重置为空
}
else
setTimeout(getIdEx,200);
)
}
function getVals(){
$('#inputId').blur(function() {
getval= $(this).val();
});
这样写,两种方法 :1、赋予一个全局变量。2、写一个<input type="hidden" />离开焦点时候,赋予这个<input type="type"> 然后就可以搞定了。
<!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>
<title></title>
<style>
*
{
margin: 0px;
}
</style> <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript">
$(function($) { var sss;
$("input:text").blur(function(event) {
sss = $(this).val();
});
$("#Button1").click(function(event) {
alert(sss);
});
});
</script></head>
<body>
<input id="Text1" type="text" />
<input id="Text2" type="text" />
<input id="Text3" type="text" />
<input id="Button1" type="button" value="button" />
</body>
</html>