Reputation: 1125
Need to get the typed value after typing using JavaScript but function not working.
my code:
<input onkeyup= "myfunction()" type="number" name="textboxname" value="">
<script>
function myfunction()
{
alert($(this).val());
}
</script>
Upvotes: 1
Views: 672
Reputation:
Give id to your input field
and use $('#id').val()
function
So your code should be
<input onkeyup="myfunction()" id="my_id" type="number" name="textboxname">
<script>
function myfunction() {
alert($('#my_id').val());
}
</script>
Upvotes: 0
Reputation: 4557
You can pass to your function the value as a parameter
<input type="text" onkeyup="myfunction(this.value)">
<script>
function myfunction(value) {
console.log(value)
}
</script>
Upvotes: 2