I have many inputs in the HTML page. I want that when i enter in the input then update it's value attribute with updated text shown in the input field
$("input").on("change paste keyup", function() {
var changee = $(this).val();
$(this).val(changee);
});
This is the code which i am using in jQuery
<input value="" type="number" class="changevalue"/>
<input value="" type="number" class="changevalue"/>
<input value="" type="number" class="changevalue"/>
<input value="" type="number" class="changevalue"/>
As you can see there are multiple inputs with same class and input type I want to update its value attribute with its updated text which i will entered
This should work, you don't have to set the value to $(this) but rather to all Elements that you want:
$(function() { $("input").on("change paste keyup", function() { var changee = $(this).val(); $('.changevalue').val(changee); }); });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input value="" type="number" class="changevalue" /> <input value="" type="number" class="changevalue" /> <input value="" type="number" class="changevalue" /> <input value="" type="number" class="changevalue" />
$("input").on("change paste keyup", function() {
$(this).attr('value', $(this).val())
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.