這種把這些代碼在一個JavaScript文件(.js文件),然後在你的web表單文件,添加引用.js文件標籤:
<script language="JavaScript" src="scripts.js"></script>
第二種可能性是把這些代碼的腳本標籤中在你的web表單文件:
<script>
var rotation = function(){
$("#image").rotate({
angle:0,
animateTo:360,
callback: rotation,
easing: function (x,t,b,c,d){ // t: current time, b: begInnIng value, c: change In value, d: duration
return c*(t/d)+b;
}
});
}
$(document).ready(function(){
rotation();
});
</script>
的C您需要確保首先引用jQuery以及您需要的任何其他JavaScript庫,包括您的js文件或內聯腳本標記之前。
希望這有助於
編輯:這是一個在我身邊的工作verison:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<img src="https://www.google.com/images/srpr/logo3w.png" id="image">
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
</script>
<script type="text/javascript" src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js"></script>
<script type="text/javascript">
function rotation() {
$("#image").rotate({
angle: 0,
animateTo: 360,
callback: rotation,
easing: function(x, t, b, c, d) { // t: current time, b: begInnIng value, c: change In value, d: duration
return c * (t/d) + b;
}
});
};
$(document).ready(function() {
rotation();
})
</script>
</html>
有趣......假設沒有其他文件 - 我嘗試粘貼到表單中,所有我看到的是一個谷歌圖片,沒有旋轉。我不是一個Web開發人員,所以只是好奇[我做錯了什麼](http://pastebin.com/0zwUnpmH)。 – Neolisk
你忘記了開頭