Fred J. Fred J. - 2 months ago 8
Javascript Question

jQuery selector of optional types

This jQuery selector tries to match

input
elements which have any of the following types
[text | number | email | tel]

It is failing to match the elements. how can it be done? Thx

$('input[type="text"][type="number"][type="email"][type="tel"]')

Answer

You need to have a comma separated selector:

$('input[type="text"], input[type="number"], input[type="email"], input[type="tel"]')

Another option is:

$('input').filter('[type="text"],[type="number"],[type="email"],[type="tel"]')
Comments