I have a button in my Html. If I clicked the button then two input field generates. I set a default value for the input fields. But I want to change the value. Whenever I change any value, I try to get the changed value of the input field through jQuery. But I can not access that. I only get the event.target
. But I want the changed value. So far I tried the following.
<button type='button' id="add">click</button>
<div id='cloneDoc'></div>
<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<script>
$(document).ready(function() {
$("div").change(function(event) {
console.log(event.target);
});
});
document.getElementById("add").addEventListener("click", function() {
var htmlClone = '<input type="number" name="a" value="50" /><br><input type="number" name="b" value="46" /><br><br>'
document.getElementById('cloneDoc').innerHTML += htmlClone;
});
</script>