i have a button and on the click event i want to read the value from a dropdown based on a class name. I want to grab the previous instance of this class.
i know i can do this to get the exact previous value but how do you add the class condition?
var teamId = $(this).prev().val();
prevUntil is doing exactly what you ask:$(this).prevUntil('some_selector')Scratch that. prevAll allows you to pass in selector. You can also return the nearest matched sibling with
:first:.prevAll('.my_class:first').An example