jQuery在Firefox中不起作用

Ram*_*o M 4 html firefox jquery

jQuery在Firefox中不起作用.它在IE和谷歌浏览器中运行良好,但当我试图在Mozilla Firefox中运行我的应用程序时,jQuery无效.任何猜测? 这是我的一段代码

<!DOCTYPE HTML PUBLIC>
<html>
   <head>
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
      <style>
         div{
         width:200px;
         height:100px;
         border:1px solid red;
         }
      </style>
   </head>
   <body>
      <div> One</div>
      <div>Two</div>
      <div>Three</div>
   </body>
   <script>
      $('div').click(function(){
       alert("Hello.....");
      });
   </script>
</html>
Run Code Online (Sandbox Code Playgroud)

小智 9

你应该使用dom ready事件

$(document).ready(function(){
  $('div').click(function(){
   alert("Hello.....");
  });
});
Run Code Online (Sandbox Code Playgroud)