Reputation: 405
I have two multiple input fields as shown below.
<input name='mark[]'/><input name='remark[]'/><br/>
<input name='mark[]'/><input name='remark[]'/><br/>
<input name='mark[]'/><input name='remark[]'/><br/>
Now when I input some value in the first mark[]
then I want to copy it to the first remark[]
. How to do this using jQuery or script?
Upvotes: 0
Views: 88
Reputation: 7970
You input
event and find next div
with $(this).next("input[name='remark[]']")
$("input[name='mark[]']").on('input', function() {
$(this).next("input[name='remark[]']").val($(this).val());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input name='mark[]'/><input name='remark[]'/><br/>
<input name='mark[]'/><input name='remark[]'/><br/>
<input name='mark[]'/><input name='remark[]'/><br/>
Upvotes: 3