i have a div where i am running a for loop. Which is creating the below divs based on the number of rows in the fields.
<div class="parent">
<p style=" font-family: Times New Roman;color:#a0a0a0; ">
Content 1 goes here.........
</p>
<div class="child">
<span> <a class="likebtn">Like</a> </span>1 people like this
</div>
<hr/>
</div>
the above shown div is in a for-each loop i.e creating multiple divs same like this with different content on it.
Now i am trying to call my jquery function , if users click on any like button residing into the div. I tried the below function but my function is not getting call. Please help me , why regarding this issue.
<script type="text/javascript">
$('.parent .child .likebtn').click(function(e)
{
alert("function called");
});
</script>
And one thing,div's are created dynamically, if i write my above javascript code just after my for-each loop then my function is getting called. It's not good practice to write javascript function in Controller. I am using COdeigniter framework. Plase help me, i have to specify this function either in head or body
LIKE, nothing happen?