-1
我不能似乎發現什麼問題我嘗試創建使用jQuery pluging easing.js ANS以及jQuery的1.11.0.min.js我不斷收到錯誤的未定義變量。我哪裏錯了?
$(function(){
//catch all clicks
$("a").click(function(){
// check if it has a #
if(this.hash){
// get rid of the # sign
var hash = this.hash.substr(1);
// get position ofd the links name
var $toElement = $("a[name="+hash+"]");
var toPosition = $toElement.position().top;
// scroll animate to postion
$("body,html").animate({
scrollTop : toPosition
},2000,"easeOutExpo");
return false;
}
});
});
簡單易於滾動效果IM,甚至當我嘗試像這樣我仍然得到了同樣的錯誤:
$(function(){
//catch all clicks
$("a").click(function(){
// check if it has a #
if(this.hash){
// get rid of the # sign
var hash = this.hash.substr(1);
// get position ofd the links name
var $toElement = $("a[name="+hash+"]");
var $toPosition = $toElement.position().top;
// scroll animate to postion
$("body,html").animate({
scrollTop : toPosition
},2000,"easeOutExpo");
return false;
}
});
});
哪個變量應該是'undefined'?在第一個和第二個中使用'toPosition'的兩個例子之間唯一的區別是什麼? –
錯誤在這一行上踢出:var toPosition = $ toElement.position()。top; – Code
this.hash?那是假設得到的? – Bilal