I have a PHP file that is generating HTML elements, and is being called from AJAX when the page loads. What I am looking to do is apply JQuery to the dynamically generated elements, so for each time a label, generated from the PHP file, is clicked something happens. I tried placing the JQuery code in the PHP file and echo it out, but that didnt work, I also placed the code in the HTML page, where the AJAX is being called, but that didnt work either.
In my HTML I have:
<body onLoad="javascript:getLabels();">,
This calls the php file through AJAX:
function getComments() {
var thePage ='loadLabels.php';
...
The PHP file as the line:
echo '<label id="labellink" class="ldClass">Label </label>';
which could be more then one label in the page once loaded, but all in their one <form>
, so I need to use JQuery so once the labels are loaded and I click on them, I can make something happen.