jQuery: looking through a DIV, getting name that contains WITH id that contains
I've got a very interesting need for jQuery.
I need to look into a specific DIV ID and then within that DIV, find an input thats name contains a certain string but is also checked.
var exclusionsFridayChecked = $("#divExclusions").find("input[id~='Fridays'][typ开发者_运维技巧e='checked']").length;
// hoping to get '1' if it is checked
But that doesn't work... my syntax is off.
The ~=
selector "selects elements that have the specified attribute with a value containing a given word, delimited by spaces".
Since ids cannot contain spaces, I'm guessing that you want *=
, which "selects elements that have the specified attribute with a value containing the a given substring".
So, you can try using
$("#divExclusions input[id*='Fridays']:checked")
///.length should be a function so .length() EDIT: NOT WORKING
Maybe jQuery returns as an array so you could try using $("#divExclusions").find("input[id~='Fridays'][type='checked']")[0].length
精彩评论