Javascript 如何使$(“text[placeholder]”在IE中工作
我的代码包含以下行:Javascript 如何使$(“text[placeholder]”在IE中工作,javascript,jquery,css,internet-explorer,internet-explorer-8,Javascript,Jquery,Css,Internet Explorer,Internet Explorer 8,我的代码包含以下行: $(":text[placeholder], :password[placeholder]").each(function(){ //some code }); 它在chrome和ff上运行良好,但在IE8中出现以下错误 Object doesn't support this property or method 如何解决此问题?或者,您可以尝试以下方法: $("input[type='text'], input[type='password']").f
$(":text[placeholder], :password[placeholder]").each(function(){
//some code
});
它在chrome和ff上运行良好,但在IE8中出现以下错误
Object doesn't support this property or method
如何解决此问题?或者,您可以尝试以下方法:
$("input[type='text'], input[type='password']").filter(function(){
var attr = $(this).attr('placeholder');
return typeof attr !== 'undefined' && attr !== false;
}).each(function(){
//some code
});
属性的检查代码借用自我猜您的代码中没有使用该引号?它在任何地方都不起作用。@adeneo:IE10不支持
占位符
和必需的
属性?您是否尝试过:$('input[type=“text”],input[type=“password”]”)
不要使用:text
,:password
。它们是!!使用输入[type=“text”][占位符]
,等等