1

I am having three checkboxes in my page i want to get all selected checkboxes values how can i achieve this using normal for loop in jquery.

for ( var i = 0; i < $(":checkbox:checked").length; i++ ) { 
alert($(":checkbox:checked")[i].attr('id'));
}
1
  • Thanks man for your quick and exact response. Commented Oct 9, 2013 at 6:13

2 Answers 2

1

Try this,

$checkboxes=$(":checkbox:checked");
for ( var i = 0,len=$checkboxes.length; i < len; i++ ) { 
    alert($($checkboxes[i]).attr('id'));
    // or simply use alert($checkboxes[i].id);
}

Fiddle

Sign up to request clarification or add additional context in comments.

Comments

1
var selectedcheckbox= $(":checkbox:checked");  

  for ( var i = 0; i < selectedcheckbox.length; i++ ) { 
    alert(selectedcheckbox.eq(i).attr('id'));
    }

reference eq

see demo

Comments

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.