HTML代碼:

jQ代碼:
//獲取id focus()是處理獲取焦點(diǎn)的方法
$("#email").focus(function(){
var txt_value = $(this).val();//獲取輸入框的值
if(txt_value=="請(qǐng)輸入郵箱地址"){
$(this).val("");//如果輸入框的值是請(qǐng)輸入郵箱地址? 聚焦后 輸入框的值為空
}
});
//獲取id focus()是處理失去焦點(diǎn)的方法
$("#email").blur(function(){
var txt_value = $(this).val();//獲取輸入框的值
if(txt_value==""){
$(this).val("請(qǐng)輸入郵箱地址");//如果輸入框的值是空? 聚焦后 輸入框的值為請(qǐng)輸入郵箱地址
}
})
$("#password").focus(function(){
var txt_value = $(this).val();
if(txt_value == "請(qǐng)輸入密碼"){
$(this).val("");
}
})
$("#password").blur(function(){
var txt_value = $(this).val();
if(txt_value == ""){
$(this).val("請(qǐng)輸入密碼");
}
})