因此,对于输入(或其他类型的 el)上的默认文本交换,我有这个片段
<input class="js_text_swap" type="text" value="输入你的邮箱" />
if($('.js_text_swap').length > 0) {
$('.js_text_swap').each(function() {
var that = $(this),
值 = that.val(); // 记住默认值
那.focusin(函数(){
如果(that.val() === 值){
that.val('');
}
});
那.focusout(函数(){
if(that.val() === '') {
那.val(值);
}
});
});
}
所以我的问题是:
1)有人对此有更好的解决方案吗?
2)有谁知道如何使用实时添加的元素(在页面加载后添加 js)使这项工作?
谢谢