I use my program <textarea>
And every time a user enters a new value, it always gives me the first value. But I always want the last amount this is my code:
<textarea id='txtBackStatus' rows='5' cols='34' onClick = "Message()">
<script>
function Message(){
var result= $('#txtBackStatus').val();
}
</script>
You need to use an 'onChange' function instead of 'onClick'
Delete the 'onClick' attribute and then try this below
<script type="text/javascript">
$("#txtBackStatus").on('change', function() {
var result = $('#txtBackStatus').val();
console.log(result);
});
</script>
You need the .change()
method to get the latest value
$( "#txtBackStatus" ).change(function() {
var result = $('#txtBackStatus').val();
});
For more information refer here .
Please also note that this event is limited to <input>
elements, <textarea>
boxes and <select>
elements.
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.