Reputation: 1791
How can I select first checked checkbox from div with class "site"?
I guess it should be something like that but this doesnt work:
$(".site :checkbox :checked :first")
Upvotes: 1
Views: 1181
Reputation: 16524
$(".site :checkbox")[0].checked);
Demo: http://jsfiddle.net/nyus6/
Upvotes: 0
Reputation: 40066
$(".site input[type='checkbox']:checked:first")
Demo: http://jsfiddle.net/TRAk2/
Use the Attribute Equal Selector to select the type of an input
.
Upvotes: 2
Reputation: 318518
Use $('.site input:checkbox:checked:first")
It searches for input
tags that are checked checkboxes below .site
and then returns the first element that matches these criteria.
Upvotes: 2