2013-04-09 61 views
-3

I`ve一直試圖讓這個例子的工作,但在所有的(使用VS2010)沒有成功:Jquery的例子不工作(在IE瀏覽器進行測試,Chrome和Firefox)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %> 

<!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> 
    <style type="text/css"> 
     #algo 
     { 
      width: 200px; 
      height: 200px; 
      color: White; 
      background-color: Red; 
      border: 4px solid black; 
      margin: 100px 0px 0px 80px; 
     } 
    </style> 
    <script type="text/javascript" src="jquery.js"> 
     $(document).ready(function() { 
      $('#algo').animate({ 'margin-top': '300px', 'margin-left': '400px' }, 1000); 
     }); </script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div id="algo"> 
     <p> 
      lol</p> 
    </div> 
    </form> 
</body> 
</html> 

我已經試過縮小的版本,但它仍然無法正常工作...有什麼我失蹤?

+0

在document.ready中,運行alert(「jquery loaded」);'。任何結果? – tymeJV 2013-04-09 18:17:07

+2

這裏似乎沒有任何jQuery導入。 – 2013-04-09 18:17:36

+0

我忘了把jquery導入,但是當我試圖做這個例子之前,即使與導入,它不工作。 – Jvam 2013-04-09 18:22:52

回答

3

你應該拔出SRC =的jquery.js參考,並添加它上面的鏈接,jQuery的,像這樣:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 

    <script type="text/javascript"> 
      $(document).ready(function() { 
//then do what ever you intend to do 
      }); 
    </script> 
1

你缺少JQuery的參考..嘗試像下面這將幫助你...

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
    <script type="text/javascript"> 
    $(document).ready(function() { 
     $('#algo').animate({ 'margin-top': '300px', 'margin-left': '400px' }, 1000); 
    }); 
    </script> 
相關問題