forum

Home / DeveloperSection / Forums / .change event not work as dynamic as expected

.change event not work as dynamic as expected

Anonymous User 1572 23-Nov-2014

I'm new to javascript, I'm using jquery, this is my html with php code:

<form action="" method="POST" enctype="multipart/form-data">
    <h1>Quantity 1</h1>
    <input id="btn1" type="number" name="cantpag" value="<?php echo $cp; ?>">
 
    <h1>Quantity 2</h1>
    <input id="btn2" type="number" name="cantreinv" value="<?php echo $cr; ?>">
 
    <input type="submit">
</form>

Here is my JS:

<script>
$(document).ready(function(){
    $(document).on('change','#btn1',function(){
        alert('works');
    });
});</script>

When I change the value of "#btn1", nothing happens immediately, instead, I must press tab or somwhere else to have the alert show up. Is there any way for this to be instant, as in, just adding or removing a number from the input field triggers the alert?


Updated on 24-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By