0

I am trying to use Jquery to trigger the event when user change the value in my input.

It is supposed to be fairly easy, however, I tried all the ways but none of them works for me.

Here is my HTML:

<input id="size" type="text" name="Size[mm]" style="width:40px; margin-top:5px; padding-left:10px;" value="1.00" maxlength="6" size="10">

Here are my jQuery:

I tried:

<script>
$('#size').bind('keyup mouseup change',function(){
       alert('Yeah!');
});
</script>

And

<script>
$("input#size").change(function(){
          alert('Yeah!');
}).change();
  </script>

And

<script>
$("#size").change(function(){
          alert('Yeah!');
});
</script>

However, none of these works and nothin happens in my Firebug..

Any ideas?

Thanks

2
  • nothing happens in your firebug? What does that mean? Commented Oct 9, 2012 at 2:54
  • Consider using document ready handler. Commented Oct 9, 2012 at 2:55

1 Answer 1

4

If they are not working, you are probably adding the event handlers before the element is rendered. Use document ready.

<script>
    $( function(){
        $('#size').bind('keyup mouseup change',function(){
            alert('Yeah!');
        });
    });
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.