I have a problem to run a second process that run under JQuery as the code below.
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head>
<body>
<script type="text/javascript" src='jquery-1.6.2.min.js'> </script>
<div id="displayArea1">
</div>
<br/>
<div id="displayArea2">
</div>
<input id="btnSet" type="button" value="Set The Value" />
<script>
//The input that should i use
var itemToPrintOut1 = "[Input1 (working)] Search <strong style='cursor:pointer' title='Click here'>IP{<span id='ip1'>192.168.2.56,192.168.2.89,192.168.2.75</span>}</strong> that has accessed to MAIL-SERVER{192.168.2.8}";
var itemToPrintOut2 = "[Input2 (not working)] Search <strong style='cursor:pointer' title='Click here'>IP{<span id='ip2'>192.168.2.56,192.168.2.89,192.168.2.75</span>}</strong> that has accessed to MAIL-SERVER{192.168.2.8}";
$("#displayArea1").html(itemToPrintOut1); //If I enable this line, it is works as what i want(because it is using jquery)
$("#btnSet").click(function(){
$("#displayArea2").html(itemToPrintOut2);
});
$("#ip1").click(function(){
alert("Normal method, data = " + $("#ip1").html());
});
$("#ip2").click(function(){
alert("The method I should use, data = " + $("#ip2").html());
});
</script>
</body>
The first time(while loading) it will display itemToPrintOut1 text and I can click on the IP address. I have no issue on that!
But when i click the button and display the second text itemToPrintOut2, I cannot click the IP anymore.
Can anyone help me on how to make sure the second output can be used with JQUERY as well. There is so many things that is also related to this issues to me.
Is it related to JQuery loading?
Thanks
You may use .live() instead of .click() for binding events at run-time. Since .live() is deprecated you may want to try .on() method.