Say I have a jquery function within JavaScript and I have this code so far, which works great:
jQuery('div[class="someClass"] input[type="text"]').each( function() { //some code} . . .
In the above code, how can I target multiple types of inputs such as textArea, drop-down list etc. I am pretty new to jQuery so I am not aware of the format a google search did not bring up anything of much relevance! Please help.
If you’re happy to select all descendent elements that are of these types:
inputtextareaselectbuttonyou can use the
:inputselector.Otherwise, you can do this in a big selector using the multiple selector as Niklas suggests. One last option is to shorten this by using two selections. This may be slightly slower, but will be significantly more readable:
Note that I have used the class selector to make your selector a bit neater.