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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:52:34+00:00 2026-05-27T13:52:34+00:00

Info: jQuery 1.6.0 HTML checkbox: First I’ve made sure jQuery is loaded with: if(jQuery)

  • 0

Info: jQuery 1.6.0
HTML checkbox:

First I’ve made sure jQuery is loaded with:

if(jQuery) {
    alert("loaded");
}

And this is the case, it’s loaded.
Then immidiately the line after that I use:

var returnvalue = jQuery("#mycheckbox").attr("checked");
alert(returnvalue);

This, for some reason, always alerts ‘undefined’. I’m 100% sure the ID exists. I’ve also tried the following method:

jQuery("#mycheckbox").find('input[type="checkbox"]').each(function(){
    alert("foo");
    if (jQuery(this).is(":checked")) 
        ReturnVal = true;
});

But this doesn’t even pop up the alert.

What am I doing wrong? I’m by far a jQuery or Javascript expert, but this should work… right?

Edit:
I’ve tried:

jQuery(document).ready(function() {
    alert(id);
    var returnvalue = jQuery("#" . id).prop("checked");
    alert(returnvalue);
});

The alert(id) gives me the proper ID, but alert(returnvalue) returns undefined.

I’ve also tried:

if(jQuery) { 
    alert("loaded");
} 
jQuery(function() {
    alert(id);
    var returnvalue = jQuery("#" . id).attr("checked");
    alert(returnvalue);
});

Same result

Edit2:
After using .prop AND appending the id with a ‘+’ instead of a ‘.’ (PHP habit), it works. Thank you all for your help!

  • 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-05-27T13:52:34+00:00Added an answer on May 27, 2026 at 1:52 pm
    • If you’re using jQuery 1.6 or later, use prop() instead of attr():
    var returnvalue = jQuery("#mycheckbox").prop("checked");
    

    This is because if you didn’t include an explicit checked attribute with the element, then the attribute is undefined though the property will have its default.


    • You need to eliminate the .find():
    jQuery("#mycheckbox").each(function(){
        alert("foo");
        if (jQuery(this).is(":checked")) 
            ReturnVal = true;
    });
    

    Including your HTML in the question would be helpful.

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

Sidebar

Related Questions

I am following this tutorial: http://www.9lessons.info/2011/03/live-table-edit-with-jquery-and-ajax.html My addition is most content is ajax/json/dynamic. I
I have this html: <div id=list1>info needed for jquery script</div> <tr> <td><button class=button green>Click
I have a file, say 'file1.html', loaded into a div via jQuery $('#info').load('info/file1.html'); I
How do I rewrite this insert html Jquery: var element = findLastInput(this).clone(); element.insertAfter(findLastInput(this)); This
I have this jQuery function function getData(jsonLink){ $(.scrollable .items).html(<img class='loadGif' src='/sites/all/themes/zen/journeyon/images/ajax-loader.gif' alt='' />); $.ajaxSetup({
I've had this problem many times: I create HTML dynamically via jQuery, and in
is it possible to make a jquery/javascript call like <span onclick=$('#dialog-2').html($.get('http://url.com');>Info</span> direct from html
I'm trying to pullout some info from an external site using jQuery and Adobe
Background info : I was handed a Tool, which was made using MS-Access 2007,
I've searched hi and low for info regarding this but to no avail. Basically

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.