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

  • SEARCH
  • Home
  • 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 8173623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:13:56+00:00 2026-06-06T22:13:56+00:00

Note, this is not a duplicate of .prop() vs .attr() ; that question refers

  • 0

Note, this is not a duplicate of .prop() vs .attr(); that question refers to the basic functionality of prop vs attr, while this question is specific to their differences as setters.

In trying to narrow down what should be set using .prop(), vs what should be set via .attr() when creating a new element, in tests with jQuery 1.7.2, I find that prop is approx 2.5 times faster, so it seems preferable.

The only list of things to be set using attr that I could find gives these for attr:

accesskey, align, background, bgcolor, class, contenteditable, contextmenu, data-XXXX, draggable, height, hidden, id, item, itemprop, spellcheck, style, subject, tabindex, title, valign, width

  1. is this complete (ie, anything not in that list – such as min, max, step, etc – should use prop)?

  2. in testing, some of those seem to work fine when set using prop. Testing the above list, I’ve had no issues setting the following with prop:

    id, class, align, contenteditable, draggable, hidden, spellcheck, tabindex, title

  3. Is there some reason, for that list of "stuff to set with attr that still work when set with prop", why it should still be set with attr? If not, then 250% faster performance when creating a basic <div id="foo" class="bar" draggable="true" title="zipzap"> seems good to me… 🙂

  • 1 1 Answer
  • 0 Views
  • 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-06-06T22:13:57+00:00Added an answer on June 6, 2026 at 10:13 pm

    I cannot find any complete list online. Everyone who gives any kind of a list just copies the partial one given in the jQuery 1.6 blog post. Regarding #3, Starx sortof addressed this in his comment to an answer here. http://timmywillison.com/ goes into better detail with a decent discussion. MDN and the W3C specs also mentions that there are various interfaces from attributes where they can be set as if they were properties ( https://developer.mozilla.org/en/DOM/element ), though MDN doesn’t actually list which ones those are. MDN does mention that using the property interfaces as setters is more brittle than using getAttribute:

    “While these interfaces are generally shared by most HTML and XML elements, there are more specialized interfaces for particular objects listed in the DOM HTML Specification. Note, however, that these HTML interfaces are “only for [HTML 4.01] and [XHTML 1.0] documents and are not guaranteed to work with any future version of XHTML.” The HTML 5 draft does state it aims for backwards compatibility with these HTML interfaces but says of them that “some features that were formerly deprecated, poorly supported, rarely used or considered unnecessary have been removed.” One can avoid the potential conflict by moving entirely to DOM XML attribute methods such as getAttribute().”

    However, it seems safe to assume for now that any HTML5 doctype page rendered in Firefox and Chrome is already in an environment where ‘deprecated, poorly supported’, etc interfaces have already been removed.

    Thus I’ve tested every attribute, as well as the non-attribute properties mentioned in the jQuery blogs, against every every HTML element type, using boolean, string, and int values.

    Using 1.7.2 and 1.8pre, whether you call .prop() or attr(), jQuery will internally always actually use .prop for:

    async, autofocus, autoplay, checked, controls, defer, disabled, hidden, loop,
    multiple, open, readonly, required, scoped, selected
    

    For HTML elements (not considering window, document, etc here), jQuery will not set any of the following attributes unless you use .attr():

    accept-charset, accesskey, bgcolor, buffered, codebase, contextmenu, datetime,
    default, dirname, dropzone, form, http-equiv, icon, ismap, itemprop, kind, 
    language, list, location, manifest, nodeName, nodeType, novalidate, pubdate, 
    radiogroup, seamless, selectedIndex, sizes, srclang, style, tagName
    

    And finally, jQuery will set the following list of attributes with either .prop() or .attr(). In the first list above, jQuery always uses .prop(), regardless of whether you use .attr() or .prop(). For the attributes in this list, jQuery uses whatever you use. If you use .prop(), jQuery uses .prop(), and vica versa. In either case, the result is the same. So ignoring any potential semantic considerations, just with regards to prop() being ~2.5 times faster than .attr(), the jQuery 1.6.1 blog post suggests that .attr() be used, but .prop() can be used instead, with significant increase in performance:

    accept, action, align, alt, autocomplete, border, challenge, charset, cite, 
    class, code, color, cols, colspan, contenteditable, coords, data, defaultValue, 
    dir, draggable, enctype, for, headers, height, hidden, high, href, hreflang, 
    id, keytype, label, lang, low, max, maxlength, media, method, min, name, 
    optimum, pattern, ping, placeholder, poster, preload, readonly, rel, required, 
    reversed, rows, rowspan, sandbox, scope, shape, size, span, spellcheck, src, 
    srcdoc, start, step, summary, tabindex, target, title, type, usemap, value, 
    width, wrap
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Follow-up question to this question : (note that this is not a duplicate, I'm
(note that this question is not about CAS, it's about the May fail spuriously
NOTE: This question is inspired by the git-svn branching question and NOT a duplicate!
(Note: Please do not mark this question as duplicate. This question is based on
Note this is not a duplicate of this similar but different question ! My
(Note: This is not a question about what is the best way with code
Please note this is not a question about online/hosted SVN services. I am working
Please note that this is not homework and i did search before starting this
Does .NET Transliteration library exists ? Note that this is not translation, something like
Please note this is not duplicate of File r/w locking and unlink . (The

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.