jquery插件的多次使用

jquery插件的多次使用,jquery,jquery-plugins,Jquery,Jquery Plugins,我已经创建了一个标签滑块插件,我正在我的页面中使用它 但当我想用它两次,它只适用于最后一个 代码如下: $.fn.tabbed = function(){ height= $(window).height(); children= this.children().eq(0).find('li'); length= children.length; width= $('.content li').width(); ulwidth=length*width; ul= this.find("ul.co

我已经创建了一个标签滑块插件,我正在我的页面中使用它

但当我想用它两次,它只适用于最后一个

代码如下:

$.fn.tabbed = function(){
height= $(window).height();
children= this.children().eq(0).find('li');
length= children.length;
width= $('.content li').width();
ulwidth=length*width;
ul= this.find("ul.content");

ul.css('width',ulwidth);
children.click(function(){
    margin=$(this).index()*width;
    ul.animate({'margin-left':-margin},1000);
});

}

如果没有任何局部变量,请使用
var
来声明它们,这样可能会起作用。具体来说,每当您多次使用该插件时,您都会覆盖您的全局
ul
变量,这会导致问题,但请不要只是修复该变量;没有理由使用所有这些全局变量。

你的问题到底是什么??我在这里没有看到任何具体问题。。