I cant seem to get the following working:
$('input:not([type=radio][type=checkbox])').live('click', function() { alert("You haven't clicked a radio or checkbox!"); });
Have tried a few different syntax's, can anyone help me out on this one.
Cheers
Charlie
You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order.
With jQuery, you can chain together actions/methods. Chaining allows us to run multiple jQuery methods (on the same element) within a single statement.
jQuery :not() SelectorThe :not() selector selects all elements except the specified element.
You're confusing the multiple selector with the multiple attribute selector. You should write:
$("input:not([type=radio], [type=checkbox])");
The multiple attribute selector [type=radio][type=checkbox]
matches the elements whose type
attributes are equal to both radio
and checkbox
, which cannot happen in this universe.
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