I have several radios that use the same function so I use the selector in this way _$('input[name=radio1]')
but the question is if I can simplify the selector more to the level of placing all the names inside the base selector, let me explain, leave it like this:
_$('input[name=radio1|radio2|radio3]')
But I did not find information about it, it would be very useful like this and not have it this way:
_$('input[name=radio2] input[name=radio2] input[name=radio3]')
I don't know if the way I expose exists but I hope there is a more feasible solution, aaah by the way, I only use a limited number of radios than there really are.
PS: I use the "var _$ = jQuery.noConflict();" because I use other scripts that use the "$".
Selectors by attributes (MDN) have the following options:
In your example, they all start
radio
with , so you could use as a selector:both in jQuery and with the method
document.querySelectorAll
In this case you could use:
Which selects all inputs
name
that start with "radio".Yes you can, the selector would look like the following: