Need help with a JQuery Selector that returns all checked checkboxes that are children of a node with a specified class
Annoyingly enough, setting the cssClass property of an ASP.NET checkbox control renders HTML like so instead of just adding the class attribute to the input tag:
<span class="myclass">
<input id="chkBox1" type="checkbox" name="chkBox1" />
</span>
So here I am trying to write a Jquery filte开发者_JAVA百科r that finds all of the checked checkboxes that are nested inside a span tag with the class "myclass" specified.
This is what I have so far, but it doesn't seem to be working.
$(".myclass input[type='checkbox']:checked")
Anyone see what I am doing incorrectly?
I'd also accept a solution that tells me how to make the checkbox control just put the dang class attribute on the input control instead of wrapping a span around it.
This should work:
$("span.myclass :checkbox")
Do you also need them checked? Then like so:
$("span.myclass :checkbox:checked")
I actually don't think you need the input type because only a checkbox can be true for :checked so you could write $(".myclass").find("input:checked") and it should probably be fine
精彩评论