It seems that the only way to select a checkable input that is actually checked is to use the :checked selector.
Is there a technical reason why this does not work:
$("INPUT[checked]")
whereas it seems to work for other attributes?
Because you would need to put the value for an attribute. But what is it? You write in XHTML checked="checked", in HTML4/5 just plain checked. The DOM model should store it as true.
$('input[checked="checked"]'); // Poor
$('input[checked=true]'); // Maybe
But it is fiddly because of potential browser differences, and checking a boolean, so there is a specific way to do it.
$('input:checked'); // Correct
The internal implementation just checks the elements .checked attribute.
From v1.5.1:
filters: {
// ...
checked: function( elem ) {
return elem.checked === true;
},
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With