I wrote a code that basically selects all input type=text element like this:
$('.sys input[type=text]').each(function () {}   How do I change it to select input[type=text] or select?
Using a normal css selector:
$('.sys input[type=text], .sys select').each(function() {...})   If you don't like the repetition:
$('.sys').find('input[type=text],select').each(function() {...})   Or more concisely, pass in the context argument:
$('input[type=text],select', '.sys').each(function() {...})   Note: Internally jQuery will convert the above to find() equivalent
http://api.jquery.com/jQuery/
Internally, selector context is implemented with the .find() method, so $('span', this) is equivalent to $(this).find('span').
I personally find the first alternative to be the most readable :), your take though
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