jQuery没有在我的HTML页面上工作

时间:2013-05-06 07:44:29

标签: javascript jquery html

jQuery无法在我的HTML页面上运行。可能是一些代码/语法问题。需要从一双好眼睛看一下。

<head>
<script src="../common/js/jquery-1.9.0.js"/>
<script>
$(document).ready(function(){
  $("#insert").click(function(){
      alert("ok");
  });
 });
</script>
</head>

<body>
    <input type="submit" id="insert" value="Insert"/>
</body>
</html>

我的文件在那里我确定,但我的警报没有弹出。请帮忙

3 个答案:

答案 0 :(得分:6)

script 不是自我结束标记,您需要在script开始标记的末尾删除正斜杠。

更改

<script src="../common/js/jquery-1.9.0.js"/>

<script src="../common/js/jquery-1.9.0.js"></script>

答案 1 :(得分:3)

更改此<script src="../common/js/jquery-1.9.0.js"/>

<script src="../common/js/jquery-1.9.0.js"></script>

答案 2 :(得分:2)

自我关闭脚本标签不起作用 - 你需要这个 -

<script src="../common/js/jquery-1.9.0.js"></script>