【发布时间】:2010-12-24 06:47:51
【问题描述】:
当我尝试使用 $(this).value="" 将文本输入设置为空白(单击时)时,这不起作用。我必须使用$(this).val('')。
为什么?有什么区别? jQuery中val函数背后的机制是什么?
$(document).ready(function() {
$('#user_name').focus(function(){
$(this).val('');
});
});
// error code: not working...
$(document).ready(function() {
$('#user_name').focus(function(){
$(this).value='';
});
});
【问题讨论】:
标签: jquery