I wrote a php script index.php as given below. This script will create some hyperlinks when it loads. If I click on any of these hyperlinks, it will load the output of example.php in div tag of id="myDiv".The output of example.php is again some hyperlinks and i wish to execute a jquery function when I click on these links. In this case i gave an alert inside this jquery function, but it is not executing that jquery function. The whole code is given below. Please help me to solve this problem.
<?php
$mainlinks = array("10.3.2.0","10.3.2.1","10.3.2.2");
for($i=0;$i<count($items);$i++)
{
echo "<a class='likelink' href='javascript:void(0)'>$mainlinks[$i]</a>" . "<br>";
}
?>
<html>
<head>
<script src="jquery/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(function() {
$('.likelink').click(function() {
$('#myDiv').load("example.php");
});
});
$(function() {
$('.sublink').click(function() {
alert("hello");
});
});
</script>
</head>
<body>
<div id="myDiv"></div>
</body>
</html>
And this my example.php file
<?php
$sublinks = array("abcd","efgh","ijkl");
for($i=0;$i<5;$i++)
{
echo "<a class='sublink' href='javascript:void(0)'>sublinks[$i]</a>" . "<br>";
}
?>