i have created a table with a row and 4 columns.i declared attributes class,id for td element. when i click on the td i have to call the jQuery function to load pop up box. here instead load pop up i just want to display the alert box but it doesn't work. here is my code
jQuery
<script type="text/javascript" src="js/jquery-1.5.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
alert("jquery");
$('.tbox').click(function(e) {
tb_show("ThickBox","hi.html?height=120&width=400","true");
}
});
</script>
html code:
<table>
<tr align="center">开发者_JAVA百科
<td class="tbox" id="tbox"> <?=$id?> </td>
<td class="tbox" id="tbox"><?=$zoneName?></td>
</tr></table>
how to call the jQuery?
Your event handler has not been closed properly, causing a parse error. Try:
$(document).ready(function(e) {
alert("jquery");
$('.tbox').click(function(e) {
tb_show("ThickBox", "hi.html?height=120&width=400", "true");
});
});
$(document).ready(function (e) {
$('.tbox').click(function (e) {
alert("jquery");
});
});
is this what you were asking?
Its because you are using two divs with same id. Thats why I think its not working. Trying varying the name of the divs and they will work fine
$('document').ready(function(){ $('#tbox1').click(function(){ alert("I am from div1"); }); $('#tbox2').click(function(){ alert("I am from div2"); }); });
精彩评论