猿问

vs2005 jquery问题

一段保存为html类型的文件可以运行jquery.代码如下

<html>
<head runat="server">
    <title>无标题页</title>
    <script type="text/javascript" src="script/jquery-1.4.js"></script>
 <script type="text/javascript" >
             $(document).ready(function(){
             $("#btnHide").click(function(){
             $("#divMsg").toggle();
             });
             });
    </script>
</head>
<body>
    <form id="form1" runat="server">
      <div id="divMsg">Hello World!</div>
         <input id="btnShow" type="button" value="显示" />
         <input id="btnHide" type="button" value="隐藏" /><br />
         <input id="btnChange" type="button" value="修改内容为 Hello World, too!" />
        
    </form>
</body>
</html>
而同样的代码保存为asp.net却隐藏不了,请问什么原因呢?代码如下.就是运行不了jquery

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <script type="text/javascript" src="~script/jquery-1.4.js"></script>
  <script type="text/javascript" >
             $(document).ready(function(){
             $("#btnHide").click(function(){
             $("#divMsg").hide();
             });
             });
     </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
         <div id="divMsg">Hello World!</div>
         <input id="btnShow" type="button" value="显示" />
         <input id="btnHide" type="button" value="隐藏" /><br />
         <input id="btnChange" type="button" value="修改内容为 Hello World, too!" />
    </div>
    </form>
</body>
</html>

ITMISS
浏览 318回答 1
1回答

慕码人2483693

<script type="text/javascript" src="~script/jquery-1.4.js"></script> 路径不对吧,导致jquery没有引入
随时随地看视频慕课网APP
我要回答