I need to test for placeholder support. The following works great in all modern browsers, as well as IE7, IE8, IE9:
$.support.placeholder = (function () {
var i = document.createElement("input");
return "placeholder" in i;
}());
It works, but JSLint complains about the use of in
:
Unexpected 'in'. Compare with undefined, or use the hasOwnProperty method instead.
Fine, so I'll refactor it to this:
$.support.placeholder = (function () {
var i = document.createElement("input");
return i.hasOwnProperty("placeholder");
}());
Now this passes JSLint without any errors or warnings, but it breaks in IE7 and IE8 with this old chestnut:
Object doesn't support property or method 'hasOwnProperty'
Any idea how to make JSLint happy, as well as IE7 and IE8?
in
. It's been around for a while so should have full support and it's pretty intuitive. For placeholder support, this is solid: github.com/mathiasbynens/jquery-placeholder – Samovar