1

I'm creating and append to some element some checbox. After that, if I want the value of checked checbox, I have problem:

$('#step-1').find('.checkbox').live('click', function() {
    alert($(this).attr('val')); // return correct value
    alert($(this).val()); // return strong 'no'
});
2
  • What's the question here? What bug? Commented Jun 23, 2011 at 16:01
  • You really need to improve your accept ratio. Commented Nov 3, 2011 at 11:35

1 Answer 1

1

Try using this.value:

$('#step-1').find('.checkbox').live('click', function() {
    if(this.checked){ //if the checkbox is checked
        alert(this.value);
    } 
    else {}
});
Sign up to request clarification or add additional context in comments.

4 Comments

I don't understand what the actual problem is, but you should better bind to the change event.
No change, I am using jQuery 1.6.
val() return string 'no' instead of correct value. If I use attr('val') it's return correct value of checkbox.
Why do you think jQuery 1.6 doesn't support the 'change' event?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.