我一直试图让这个例子有效,但完全没有成功(使用vs2010):
<%@ 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 :(得分: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 :(得分: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>