1

How to bind change event to dynamically generated textbox?

$("#searchtext").change(function()
{
    alert( "Handler for .change() called." );
});

$("#textbox1").live('change', function(){
    value = $("#textbox1").val();
    alert(value);
});

Both of the above functions are not working for me. Any suggestions?

4
  • Use keyup or focus event instead of change Commented Feb 24, 2014 at 8:51
  • .live() is deprecated since version 1.7, what is your jQuery version ? Commented Feb 24, 2014 at 8:52
  • Hope this will help you out [Onchange][1] [1]: stackoverflow.com/a/5787218/2219371 Commented Feb 24, 2014 at 8:54
  • may be because - you can see at least 3 questions similar to this on SO for every day Commented Feb 24, 2014 at 9:28

1 Answer 1

3

You can use on() instead of live() since live() is deprecated since version 1.7:

$(document).on('keyup','#textbox1', function() {
    value = $("#textbox1").val();   
    alert(value);
});
Sign up to request clarification or add additional context in comments.

3 Comments

working bt not on textchange. its showing popup when textbox goes out of focus
Use keydown() instead of change() event.
no it will not help. i want like google search. user types and value should be captured

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.