JQ怎么控制多个文本框获取、失去鼠标焦点事件 JQ怎么控制多个文本框获取、失去鼠标焦点事件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 例如:<input name="inputbox01" type="text" value="old content 01"><script language="javascript" type="text/javascript">//需先引用jquery$('#inputbox01').trigger("focus"); //获取焦点$('#inputbox01').trigger("blur"); //失去焦点</javascript> <input name="textbox" type="text" value="content"><script language="javascript" type="text/javascript">$('#textbox').trigger("focus"); //获取焦点$('#textbox').trigger("blur"); //失去焦点</javascript> <input type="text" value="请输入照片标签"><input type="text" value="请输入照片标签"><input type="text" value="请输入照片标签"><input type="text" value="请输入照片标签">在很多个文本下实现获取焦点使value的值清空,离开焦点显示value的值 <input type="text" value="请输入照片标签" onfocus="theforever_csdn1(this);" onblur="theforever_csdn2(this);"><input type="text" value="请输入照片标签" onfocus="theforever_csdn1(this);" onblur="theforever_csdn2(this);"><input type="text" value="请输入照片标签" onfocus="theforever_csdn1(this);" onblur="theforever_csdn2(this);"><input type="text" value="请输入照片标签" onfocus="theforever_csdn1(this);" onblur="theforever_csdn2(this);"><script type="text/javascript">function theforever_csdn1(obj){ obj.oldVal=obj.value; obj.value="";}function theforever_csdn2(obj){ obj.value=obj.oldVal;}</script> 刚在另外一个贴回答了一个一模一样的问题,果断直接拷过来。。<!DOCTYPE html><html><head> <title>test</title> <script src="jquery.js"></script></head><body> <form id="form" action="" method="get"> <input type="text" name="First name" value="First name"/> <input type="text" name="Family name" value="Family name"/> <input type="text" name="Email" value="Email..."/> <input type="text" name="password" value="password..."/> <input type="text" name="location" value="City where you live"/> <input type="submit" name="sign up" value="Sign Up"/> </form> <script> $('#form').children(':text').focus(function(){ if(!this.initValue){ this.initValue = this.value; } if(this.value === this.initValue){ this.value = ''; } }).blur(function(){ if(this.value === '' || this.value === null){ this.value = this.initValue; } }); </script></body></html> JScript code<input name="textbox" type="text" value="content"><script language="javascript" type="text/javascript">$('#textbox').trigger("focus"); //获取焦点$('#textbox').trigger("blur"); //失去焦点</javascript> 求解如何将json数据传给后台 怎么用js判断一个页面部分已经加载完成? Jquery显示和隐藏div 一个项目中(是一个大公司的项目)碰到的一个js问题求助高手 有用jatoolsPrinter的吗,有问题请教! 如何验证形如2006-12-20的字符串是一合法的日期? 用javascript如何更改文件名,在指定的位置加一个点 extjs4 tree字体大小 table的大小需要用函数计算得到。后面怎么使用这个函数阿? 怎样让ie窗口全屏显示!! 怎样让Google地图显示指定的城市? 视频流是如何由服务器端传送到网页端并播放出来的
<input name="inputbox01" type="text" value="old content 01">
<script language="javascript" type="text/javascript">
//需先引用jquery
$('#inputbox01').trigger("focus"); //获取焦点
$('#inputbox01').trigger("blur"); //失去焦点
</javascript>
<script language="javascript" type="text/javascript">
$('#textbox').trigger("focus"); //获取焦点
$('#textbox').trigger("blur"); //失去焦点
</javascript>
<input type="text" value="请输入照片标签">
<input type="text" value="请输入照片标签">
<input type="text" value="请输入照片标签">
在很多个文本下实现获取焦点使value的值清空,离开焦点显示value的值
<input type="text" value="请输入照片标签" onfocus="theforever_csdn1(this);" onblur="theforever_csdn2(this);">
<input type="text" value="请输入照片标签" onfocus="theforever_csdn1(this);" onblur="theforever_csdn2(this);">
<input type="text" value="请输入照片标签" onfocus="theforever_csdn1(this);" onblur="theforever_csdn2(this);"><script type="text/javascript">
function theforever_csdn1(obj){
obj.oldVal=obj.value;
obj.value="";
}
function theforever_csdn2(obj){
obj.value=obj.oldVal;
}
</script>
<html>
<head>
<title>test</title>
<script src="jquery.js"></script>
</head>
<body>
<form id="form" action="" method="get">
<input type="text" name="First name" value="First name"/>
<input type="text" name="Family name" value="Family name"/>
<input type="text" name="Email" value="Email..."/>
<input type="text" name="password" value="password..."/>
<input type="text" name="location" value="City where you live"/>
<input type="submit" name="sign up" value="Sign Up"/>
</form>
<script>
$('#form').children(':text').focus(function(){
if(!this.initValue){
this.initValue = this.value;
}
if(this.value === this.initValue){
this.value = '';
}
}).blur(function(){
if(this.value === '' || this.value === null){
this.value = this.initValue;
}
});
</script>
</body>
</html>
<script language="javascript" type="text/javascript">
$('#textbox').trigger("focus"); //获取焦点
$('#textbox').trigger("blur"); //失去焦点
</javascript>