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")
remove the spaces
$(".site :checkbox:first:checked")
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.
$(".site input[type='checkbox']:checked:first")
Demo: http://jsfiddle.net/TRAk2/
Use the Attribute Equal Selector to select the type of an input
.
$(".site :checkbox")[0].checked);
Demo: http://jsfiddle.net/nyus6/
精彩评论