你好,我輸入密碼類型。我想做簡單的事情。如果輸入不在焦點上,則輸入具有默認值。我試圖用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