So, I'm using jQuery with PHP, and, I am echoing out a button:
echo '<input type="button" id="button" value="Info" style="float: right;"/>';
Pretty simple, I tried using "\" for the quotations, but, that didn't make any difference (for those who will point it out.
Anyway, the jQuery portion is pretty simple:
$("#button").click(function() {
alert("Clicked");
});
Within the $(document).ready(function(){});
The echo is passed through an ajax call. If that makes any difference, and.
I do not get the alert. So if anyone can pinpoint the solution that would be great.
2 Answers 2
echo '<input type="button" id="button" value="Info" style="float: right;"/>';
$("input#button").live('click',function() {
alert("Clicked");
});
answered Feb 29, 2012 at 22:35
Ken Wheeler
1,95813 silver badges12 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
CCates
Worked, thanks, now, I just need to figure out parent classes, and, get the parent ID. That is something I can figure out on my own.
Try using " instead of ' for the quotes on the outside as PHP does not evaluate things inside single quotes.
Mark Ursino
31.5k12 gold badges54 silver badges83 bronze badges
Comments
default
liveinstead ofclicklike @ken has done below in his answer. The element doesn't exist when the event is bound, so it doesn't work.