I want to use Jquery on.(input, [...]) function to display what a user types in another input field.
Here's my code:
$(document).ready(function() {
$("input.inputtext").on('input', function() {
var inputtext = $(".inputtext").val();
$(".showinput").val(inputtext);
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="inputs">
<input type="text" class="inputtext">
<div>
<div class="inputs">
<input type="text" class="inputtext">
<div>
<div class="inputs">
<input type="text" class="inputtext">
<div>
<input type="text" class="showinput">
However, the code only shows the entered text for the first input field.
I think I have to use a for loop but I dont't know how to.