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 8840807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:33:03+00:00 2026-06-14T10:33:03+00:00

Why does jQuery don’t return value of ‘checked’ attribute? It always returns ‘checked’, no

  • 0

Why does jQuery don’t return value of ‘checked’ attribute?

It always returns ‘checked’, no matter what is in it.

<div id='div' checked='checked_value'></div>
<script>
    var attr_value = $('#div').attr('checked');
    alert(attr_value);
    // attr_value == 'checked' no matter what
</script>

http://jsfiddle.net/BbRmH/2/

It was okay, in 1.4, but when I upgraded to 1.8 it totally messed my code. I use checked attribute a lot.

  • 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-14T10:33:04+00:00Added an answer on June 14, 2026 at 10:33 am

    I believe in the more recent versions of jQuery the correct syntax would be –

    $("element").prop('checked');
    

    The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the .attr() method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior. As of jQuery 1.6, the .prop() method provides a way to explicitly retrieve property values, while .attr() retrieves attributes.

    • prop()

    I believe however, that you might be using this property incorrectly. Usually, one would just test for the existence of the checked selector. There can really only be two states. Checked and unchecked. Usually, one would use something like this –

    $('.groupOfCheckboxes:checked')
    

    This would return a list of all the matched checkboxes that are checked. You also used this property on a <div> element. This is not valid HTML. You should really stick to valid markup if you want the most consistent results across browsers.

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

Sidebar

Related Questions

what does this code performs? if(object.jquery){ .... } I don't know what jQuery attribute
Where does the jquery ajax success callback return to? I have written a request
Does JQuery have the ability to create an area that scrolls? Like I have
Does jQuery - or one of it's plugins - have equivalent functionality to the
does jquery have any plugin that prevents entering any input to a textbox that
Does jquery/javascript have any event model that you can attach to your objects? Basically
Does jQuery validation plugin have some dependencies? For example, I saw blogposts that said
Does jquery 1.4 completely compatible with jquery 1.32 ? I have lots of codes
How does jquery handle event assignment when it comes to assigning the same handler
Why does JQuery ( latest source ) tie there Ajax Request Object to a

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.