Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4237716
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:48:37+00:00 2026-05-21T02:48:37+00:00

tldr: Why does (‘placeholder’ in inputElemnt) equal true in IE8 despite no native support

  • 0

tldr:
Why does (‘placeholder’ in inputElemnt) equal true in IE8 despite no native support for the placeholder attribute? Isn’t (attribute in element) a good way to check for native support? The Javascript library Modernizer use it.

Long:
I have a small Jquery plugin called Defaultvalue ( http://unwrongest.com/projects/defaultvalue/ ). I have a small Jquery plugin called Placeholder ( https://github.com/janjarfalk/jquery.placeholder.js ). It’s basically a fallback for the HTML5 placeholder attribute.

In a recent updated I added these three lines of code. Hoping that Defaultvalue wouldn’t run if the browser had native support for the placeholder attribute.

if('placeholder' in this){
    // this is an input-element
    return false;
}

It seems to work in most browsers except IE8 and IE7. For some reason it finds the key ‘placeholder’ in this, but there isn’t, I think, any support for the placeholder attribute in IE7/IE8.

My code was inspired by this code in the Javascript library Modernizer ( http://www.modernizr.com/ ).

(function(props) {
    for (var i = 0, len = props.length; i < len; i++) {
        attrs[ props[i] ] = !!(props[i] in inputElem);
    }
    return attrs;
})('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' '));

What am I missing?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:48:38+00:00Added an answer on May 21, 2026 at 2:48 am

    Creating a new raw input element solved my problem.

    var nativePlaceholderSupport = (function() {
        var i = document.createElement('input');
        return i.placeholder !== undefined;
    })();
    
    if(nativePlaceholderSupport){
        return false;
    }
    

    var nativePlaceholderSupport = (function(){
        var i = document.createElement('input');
        return ('placeholder' in i);
    })();
    
    if(nativePlaceholderSupport){
        return false;
    }
    

    Thanks RobG, you led me to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

if (reader.is_lazy()) goto tldr; I have a background thread that does some I/O-intensive background
TLDR: Does anyone have experience of both protovis & D3.js to illuminate the differences
Update: This may be something that just isn't doable. See this TLDR: How do
TLDR: What are the pros/cons of using an in-memory database vs locks and concurrent
Since I got TLDR (too long didn't read) comments, I stripped 90% of this
TLDR I want to add some dynamic content into an Ext-JS window / popup.
tldr: Is ~90,000 super columns with 1 to 10 columns each too many in
TLDR Linking my fresh boost build with Visual Studio (/Mtd) causes boost to throw
TLDR; How do I read data from a table using Entity Framework, when the
TLDR: Started with this question simplified it after got some of it working and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.