Button Click from PHP not responding
I am repeating a button from a php script like this: print'<button id="testingbtn">TEsting</button>';
I am using id to listen to the button and alert the notification message like this:
$('#testingbtn').click(function(){
alert('working');
});
The thing is, I used the same method before and it worked for me in all browsers, but not anymore. can someone try to help me solve this problem. Thanks guys..
source to share
Point 1: Check if jquery library is included or not.
Point 2: [If point 1 is ok] where did you put your script? If you put your script before button code than using document ready function
$(document).ready(function(){
$('#testingbtn').click(function(){
alert('working');
});
});
Alternatively if you want to put your code unchanged than put your script after the button code [best practice: put them at the bottom of the page].
source to share