0

My code contains these lines :

 $(":text[placeholder], :password[placeholder]").each(function(){
    //some code
  });

It is working fine on chrome and ff but getting the below error in IE8 .

 Object doesn't support this property or method

How can I fix this ?

user1886423
  • 97
  • 2
  • 6
  • 1
    I guess you're not using that quotation in your code ? It wouldn't work anywhere around. – jAndy Dec 21 '12 at 12:23
  • @adeneo: IE10 doesn't support `placeholder` and `required` attributes ? – jAndy Dec 21 '12 at 12:24
  • have you tried this: `$('input[type="text"], input[type="password"]')` – Jai Dec 21 '12 at 12:25
  • 3
    Don't use `:text`,`:password`. They are [deprecated](http://api.jquery.com/category/deprecated/)!! Use `input[type="text"][placeholder]`, etc...instead – Engineer Dec 21 '12 at 12:36

1 Answers1

1

Alternatively you can try this:

$("input[type='text'], input[type='password']").filter(function(){
    var attr = $(this).attr('placeholder');
    return typeof attr !== 'undefined' && attr !== false;
}).each(function(){
    //some code
});

Attribute's checking code borrowed from here

Community
  • 1
  • 1
Engineer
  • 47,849
  • 12
  • 88
  • 91