<label for="a1">First:</label>
<input id="a1" class="first" type="text" name="a1" value="123">
<label for="b1">Second:</label>
<input id="b1" class="second" type="text" name="b1"> <br />
<label for="a2">First:</label>
<input id="a2" class="first" type="text" name="a2"value="3424">
<label for="b2">Second:</label>
<input id="b2" class="second" type="text" name="b2"> <br />
<label for="a3">First:</label>
<input id="a3" class="first" type="text" name="a3"value="1235">
<label for="b3">Second:</label>
<input id="b3" class="second" type="text" name="b3"> <br />
$('.second').click(function(){
var get_first = // ???
$(this).val(get_first);
})
i would like for example – if i click on input b3 then in this value now is value from a3. how can i make it with next and prev in one class?
I’m not sure I can think of a reason for doing this, but assuming I understand your requirements correctly, then this should work (currently untested):
JS Fiddle demo.
References:
:firstselector.prevAll().:textselector.val().