var t=$("#temp").click(function(){alert("1");});单击事件不管用
<html> <head> <title></title> <style type="text/css"> #page{ width:1020px; 新年祝福网页 margin-left:auto; margin-right: auto; } .nav1{ float:left; } li{ list-style-type:none; } </style> <script language="javascript" src="jquery-1.7.2.js" type="text/javascript" ></script> <script language="javascript" src="jquery162.js" type="text/javascript" ></script> <script language="javascript" type="text/javascript"> $("#topmenu .nav1 li a").bind('click',function(){alert(1);}); var t=$("#temp").click(function(){alert("1");}); var util={ openSecondMenu:function(e){ var targetName=e.target.name; switch(targetName) { case "f1": window.position="f1"; $("#second_menu").append("<li><a name='s1'>呼叫记录1</a></li>"); $("#second_menu").append("<li><a name='s2'>呼叫记录2</a></li>"); break; case "f2": break; case "f3": break; case "f4": break; case "f5": break; case "f6": break; case "f7": break; case "f8": break; case "f9": break; default:break; } } } </script> </head> <body> <div id="temp" style="background-color:red;">aaa</div> <div id="page"> <table> <tr id="menu"> <div id="top" id="topmenu"> <div class="nav1"> <li> <a name="f1">话单记录</a> </li> </div> <div class="nav1"> <li> <a name="f2">呼叫分析</a> </li> </div> <div class="nav1"> <li> <a name="f3">坐席报表</a> </li> </div> <div class="nav1"> <li> <a name="f4">队列报表</a> </li> </div> <div class="nav1"> <li> <a name="f5">实时分析</a> </li> </div> <div class="nav1"> <li> <a name="f6">语音导航</a> </li> </div> <div class="nav1"> <li> <a name="f7">短信报表</a> </li> </div> <div class="nav1"> <li> <a name="f8">传真报表</a> </li> </div> <div class="nav1"> <li> <a name="f9">其他报表</a> </li> </div> <div style="clear:both;"></div> </div> </tr> <tr id="content"> <td valign="top" width="125px" height="800px"> <div height="800px" id="second_menu" class="nav"> <li> <a>呼叫记录1</a> </li> </div> </td> <td> <iframe width="895px" height="800px" frameborder="0" src="http://192.168.100.20/admin/cdr/cdr.php?s=0" valign="top"> </iframe> </td> </tr> </table> </div> </body> </html>
页面没有加载完是找不到dom对象的
另外修改下div的id,有两个
然后就ok了