Can anyone help?
I have a change event in a text box and a click event on a button - all html.
Now, if I press a button, a click event will occur - great!
But I change something in the text box, and then I click the button, the event from the Change event happens, but itβs not, but I never get the button click event.
This is my jquery, is there any way around this. I'm lost.
$('#myTextbox').live('change', function() { $.ajax({ type: "POST", url: "test.aspx/GetDate", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { alert('the date is ' + msg.d); } }); }); $('#myButton').live('click', function() { alert('i am in click'); });
EDIT
I created a very simple html form and, of course, the click event does not fire if the change occurs first. In fact, in this example, I used the blur event ... but its
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="Scripts/jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { $('#htmlbutton').bind('click', function() { alert('i am in click'); }); $('#htmltextbox').bind('blur', function() { alert('in blur'); }); }); </script> </head> <body> <form id="form1"> <div> <input id="htmlbutton" type="button" value="button" /><input id="htmltextbox" type="text" /></div> </form> </body> </html>
source share