I need to output onto a button in realtime what is being written into a text input field.
<div class="content-loaded-via-ajax">
<input id="input" type="text" pattern="[0-9]+" name="amount">
</div>
<div class="another-content-loaded-via-ajax">
<button id="output" type="submit" name="submit">
//display output here
</button>
</div>
I would use something like this:
<script>
document.getElementById('input').addEventListener("keyup", myFunction);
var inputBox = document.getElementById('input');
function myFunction(){
document.getElementById('output').value = inputBox.value;
}
</script>
But since both the input field and the button are dynamically loaded by ajax, this doesn't work.
I would also be willing to use jQuery since it's already being used on the page anyway.
Thanks.