【发布时间】:2017-01-01 10:22:38
【问题描述】:
我正在使用 jquery 占位符文本作为搜索占位符。此搜索字段没有任何占位符,因此我添加了此文本。
$(document).ready(function(){
$('.mfilter-search').find("input[type=text]").each(function(ev)
{
if(!$(this).val()) {
$(this).attr("placeholder", "Refine Your Search");
}
});
});
我不知道这是使用 jquery 添加占位符的最佳方式。如果有人知道更简单的方法,请添加您的代码,这将非常有帮助。
【问题讨论】:
标签: javascript jquery html text placeholder