我试图让所有textareas删除焦点上的默认文本,除了类的“预填充”。 但问题是“预填充”类的textareas仍在被选中和包括在内。jQuery .not()方法无法正常工作
有关如何解决此问题的建议? 谢谢。
jQuery(document).ready(function inputHide(){
$('textarea, input:text, input:password').not($('.pre-fill')).focus(function() {
if ($(this).val() === $(this).attr('defaultValue')) {
$(this).val('');
}
}).blur(function() {
if ($(this).val()==='') {
$(this).val($(this).attr('defaultValue'))
}
});
});
'this.value'比'$(this).val()'效率更高,因为您不必首先创建jQuery对象,然后调用jQuery方法。 – 2010-10-08 22:55:23