getting data from closest input
hi yall
so im trying to figure out how to get some data, without over naming my elements but i cant seem to get it done.
ive got a little piece of html code in a php file, with a text input and a button.
i incude this php twice on the same page.
now, how do i get the value of the text input closer to the button pressed?
the code is something like
<input text>
<button>
<input text>
<button>
i haven't given any element an id. they all have classes (which is class="btn" for the buttons and "text-input" for the text inputs)
im not sure but id like to be able to get the inputted data from the input texts, without including two different inputs and two different buttons,
is it possible?
i tried this on the buttons:
onclick="alert($(this).closest('.text-input').val());" but it doesn't work.
any ideas?
thakns