Using "and" while querying on attributes?
Hi, I want to search for checkboxes that are checked AND have a certain data-* attribute
The HTML
<input id="SomeId" type="checkbox" name="MyGridName1" data-companyId="45456" />
//--This finds the checked boxes but finds all of them...
$("#SomeId input[type=checkbox]:checked").length
5
//--I want to combine the query to search for both attribute values...but couldn't get it to work
$("#SomeId input[type=checkbox]:checked input[data-companyId='45456']").length
0
//--I ended up doing this but thought thought I could do it like above somehow.
$("#SomeId input[type=checkbox]:checked").each(function () {
if ($(this).attr("data-companyId") != null) {
var companyId = $(this).attr("data-companyId")
...
}
});