$( "#address" ).focus( function () { // 地址框获得鼠标焦点 |
var txt_value = $( this ).val(); // 得到当前文本框的值 |
if (txt_value == "请输入邮箱地址" ) { |
$( this ).val( "" ); // 如果符合条件,则清空文本框内容 |
} |
}); |
$( "#address" ).blur( function () { // 地址框失去鼠标焦点 |
var txt_value = $( this ).val(); // 得到当前文本框的值 |
if (txt_value == "" ) { |
$( this ).val( "请输入邮箱地址" ); // 如果符合条件,则设置内容 |
} |
}) |
$( "#password" ).focus( function () { |
var txt_value = $( this ).val(); |
if (txt_value == "请输入邮箱密码" ) { |
$( this ).val( "" ); |
} |
}); |
$( "#password" ).blur( function () { |
var txt_value = $( this ).val(); |
if (txt_value == "" ) { |
$( this ).val( "请输入邮箱密码" ); |
} |
}) |
//另一个方法 |
$( function () { |
$( "#address" ).focus( function () { // 地址框获得鼠标焦点 |
var txt_value = $( this ).val(); // 得到当前文本框的值 |
if (txt_value == this .defaultValue) { |
$( this ).val( "" ); // 如果符合条件,则清空文本框内容 |
} |
}); |
$( "#address" ).blur( function () { // 地址框失去鼠标焦点 |
var txt_value = $( this ).val(); // 得到当前文本框的值 |
if (txt_value == "" ) { |
$( this ).val( this .defaultValue); // 如果符合条件,则设置内容 |
} |
}) |
|
$( "#password" ).focus( function () { |
var txt_value = $( this ).val(); |
if (txt_value == this .defaultValue) { |
$( this ).val( "" ); |
} |
}); |
$( "#password" ).blur( function () { |
var txt_value = $( this ).val(); |
if (txt_value == "" ) { |
$( this ).val( this .defaultValue); |
} |
}) |
}); |