23,404
社区成员
发帖
与我相关
我的任务
分享
//通用函数
//ready
var yoursfunction=function(jqueryObject){
jqueryObject.onfocus(function(){
if($(this).val()==this.defaultValue)
$(this).val("");
}).onblur(function(){
if($(this).val()=="")
$(this).val(this.defaultValue);
});
}
yoursfunction($("input"));
<input type="text" id="msgtel" name="msgtel" maxlength="50" class="single" onfocus="if(this.value=='请输入您的联系方式')this.value='';" onblur="if(this.value=='')this.value='请输入您的联系方式';" value="请输入您的联系方式">