我有一个小问题,IE 8-9不支持输入框的placeholder
属性。
在我的项目(ASP.NET)中提供这种支持的最好方法是什么?我正在使用jQuery。我需要使用一些其他的外部工具吗?
http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html是一个好的解决方案吗?
发布于 2013-02-22 17:32:33
您可以使用这个jQuery插件:https://github.com/mathiasbynens/jquery-placeholder
但是你的链接似乎也是一个很好的解决方案。
发布于 2014-11-20 11:04:05
我有几个插件的兼容性问题,对我来说,这似乎是支持文本输入占位符的最简单方法:
function placeholders(){
//On Focus
$(":text").focus(function(){
//Check to see if the user has modified the input, if not then remove the placeholder text
if($(this).val() == $(this).attr("placeholder")){
$(this).val("");
}
});
//On Blur
$(":text").blur(function(){
//Check to see if the use has modified the input, if not then populate the placeholder back into the input
if( $(this).val() == ""){
$(this).val($(this).attr("placeholder"));
}
});
}
发布于 2013-12-10 19:22:47
$(function(){
if($.browser.msie && $.browser.version <= 9){
$("[placeholder]").focus(function(){
if($(this).val()==$(this).attr("placeholder")) $(this).val("");
}).blur(function(){
if($(this).val()=="") $(this).val($(this).attr("placeholder"));
}).blur();
$("[placeholder]").parents("form").submit(function() {
$(this).find('[placeholder]').each(function() {
if ($(this).val() == $(this).attr("placeholder")) {
$(this).val("");
}
})
});
}
});
尝尝这个
https://stackoverflow.com/questions/15020826
复制相似问题