此代碼在我的頁面中沒有錯誤,所以我沒有在那裏尋找任何幫助。我只是好奇如果有一個更短的方法來做到這一點,有很多代碼重複只是每次更改一些類名稱。我可以在某種功能或循環中縮短它嗎?由於長代碼功能?
//menu
$('.aboutOne').click(function(){
$.scrollTo('.basicsRow', 1000, {axis:'yx'});
$.scrollTo('.basicsRow', 1000, {axis:'xy'});
})
$('.aboutTwo').click(function(){
$.scrollTo('.storyRow', 1000, {axis:'yx'});
$.scrollTo('.storyRow', 1000, {axis:'xy'});
})
$('.aboutThree').click(function(){
$.scrollTo('.teamRow', 1000, {axis:'yx'});
$.scrollTo('.teamRow', 1000, {axis:'xy'});
})
$('.aboutOne').click(function(){
$.scrollTo('.basicsRow', 1000, {axis:'yx'});
$.scrollTo('.basicsRow', 1000, {axis:'xy'});
})
$('.aboutTwo').click(function(){
$.scrollTo('.storyRow', 1000, {axis:'yx'});
$.scrollTo('.storyRow', 1000, {axis:'xy'});
})
$('.aboutThree').click(function(){
$.scrollTo('.teamRow', 1000, {axis:'yx'});
$.scrollTo('.teamRow', 1000, {axis:'xy'});
})
$('.titleOne').click(function(){
$.scrollTo('.homeRow', 1000, {axis:'yx'});
$.scrollTo('.homeRow', 1000, {axis:'xy'});
})
$('.docsOne').click(function(){
$.scrollTo('.startRow', 1000, {axis:'yx'});
$.scrollTo('.startRow', 1000, {axis:'xy'});
})
$('.docsTwo').click(function(){
$.scrollTo('.pinpointRow', 1000, {axis:'yx'});
$.scrollTo('.pinpointRow', 1000, {axis:'xy'});
})
$('.docsThree').click(function(){
$.scrollTo('.swipeRow', 1000, {axis:'yx'});
$.scrollTo('.swipeRow', 1000, {axis:'xy'});
})
$('.docsFour').click(function(){
$.scrollTo('.restRow', 1000, {axis:'yx'});
$.scrollTo('.restRow', 1000, {axis:'xy'});
})
$('.docsFive').click(function(){
$.scrollTo('.actionRow', 1000, {axis:'yx'});
$.scrollTo('.actionRow', 1000, {axis:'xy'});
})
$('.contactOne').click(function(){
$.scrollTo('.contactRow', 1000, {axis:'yx'});
$.scrollTo('.contactRow', 1000, {axis:'xy'});
})
$('.downloadOne').click(function(){
$.scrollTo('.downloadRow', 1000, {axis:'yx'});
$.scrollTo('.downloadRow', 1000, {axis:'xy'});
})
http://codereview.stackexchange.com/ – Alexander 2013-02-18 19:08:41
的HTML將是有益的了。 – insertusernamehere 2013-02-18 19:09:58
我相信,如果它是一個錯字,但你有元素'.aboutX'重複兩次 – Alexander 2013-02-18 19:10:55