I have a several forms, and I’d like to select only the first and second input box of each form
$("form input:nth-child(1), form input:nth-child(2)");
But this doesn’t work because each input has a label next to it, so there is no input that is nth-child(1).
Example at jsbin
You can do it using
:lt(), like this:This selects all elements that match at less-than the passed index, the first and second elements are index 0 and 1, and will match this selector 🙂