0
我是新來的,我不知道如何編寫插件。任何人都可以幫助如何編寫這個jquery函數的插件。爲jquery函數編寫插件?
$(document).ready(function(){
var offset_1 = $("li.list:first-child").position().left;
var offset_2 = $("li.list:nth-child(2)").position().left;
var totalWidth =offset_2-offset_1;
$("a.abc").click(function() {
$("#scroller").not(":animated").animate({"scrollLeft":"-="+totalWidth},300);
return false;
});
$("a.def").click(function() {
$("#scroller").not(":animated").animate({"scrollLeft":"+="+totalWidth},300);
return false;
});
});
你看看[上jQuery.com的入門教程插件(HTTP://docs.jquery。 COM /插件/創作)?請注意,調用插件的常用語法是'$(someSelector).pluginName(paramsHere)' - 我不確定這是如何適合您顯示的代碼有幾個不同的選擇器... – nnnnnn