带水印的输入(CSS和Jquery)

带水印的输入(CSS和Jquery),第1张

水印输入(CSS和Jquery)

$(document).ready(function () {
$(“:input[data-watermark]”).each(function () {
$(this).val($(this).attr(“data-watermark”));
$(this).css(“color”,”#a8a8a8”);
$(this).bind(“focus”, function () {
if ($(this).val() == $(this).attr(“data-watermark”)) $(this).val(‘’);
$(this).css(“color”,”#000000”);
});
$(this).bind(“blur”, function () {
if ($(this).val() == ‘’)
{
$(this).val($(this).attr(“data-watermark”));
$(this).css(“color”,”#a8a8a8”);
}
else
{
$(this).css(“color”,”#000000”);
}
});
});
});




欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5567078.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-14
下一篇 2022-12-14

发表评论

登录后才能评论

评论列表(0条)

保存