i have a bunch of repeating textboxes and comboboxes on an html page. I want to change the value of the textbox below the combobox when i change the combobox. So i have this code so far:
$('.myDropdown').change(function () {
var currentDropdownValue = $(this).val();
if (currentDropdownValue == "Regular") {
//CHANGE TEXTBOX BELOW THIS COMBOBOX WITH CLASS = "QUANTITY" TO 10.
}
});
here is my html
<select class="myDropdown">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<input class="quantity" type="text" />
basically, i need to figure out the right selector syntax as i was using “Closest()” but that seems to only go up the DOM tree and not past the current value.
You could use .next() to return the next item or pass it a selector if you are more picky.
No need for extra DOM Traversing like parent() or such.
Working JSFiddle: http://jsfiddle.net/CXzVe/2/.