你好,我输入密码类型。我想做简单的事情。如果输入不在焦点上,则输入具有默认值。我试图用jQuery来做到这一点。 我的HTML:jQuery模糊/焦点奇怪的情况
<input type="password" name="password" id="password" defvalue="password" class="filling-password">
我的JavaScript(jQuery的):
$('.filling-password').each(function(){
var b = $(this);
var id = this.id;
var val = b.attr("defvalue");
var textInput = '<input id="'+id+'-text" type="text" value="'+val+'">';
$(textInput).insertAfter(this);
b.hide(0);
$("#"+id+"-text").focus(function(){
$(this).hide(0);
b.show(0).focus();
});
b.blur(function(){
if ($(this).val() == "") {
$(textInput).insertAfter(this);
b.hide(0);
}
});
});
所有工作不错。但只有一次。当我点击第一次输入变空时,当我模糊输入有默认值。但如果我第三次点击什么都没有发生。哪里不对?或者也许有更好的方法来做到这一点?
对不起,我的英语。先谢谢你。
-1。 1.你不知道jQuery。 2.使用密码输入将符号转换为“*”。 – pltvs 2010-12-23 17:10:27