写了个tab切换

js

	var TAB = function () {
       var $this
 
       function tab() {
           this.init.apply(this, arguments);
       }
 
       tab.prototype = {
           init:function (obj_li, tab_div) {
               $this = this
               $this.obj = obj_li
               $this.div = tab_div
           },
           pri:function () {
              $this.obj.click(function () {
              $this.i =  $this.obj.index(this)
              $this.obj.eq($this.i).addClass('list_on').siblings().removeClass('list_on');//jq链式写法,节省性能
              $this.div.eq($this.i).removeClass("hidden").siblings().addClass("hidden")//jq链式写法,节省性能
               })
 
           }
       }
       var k = new tab($(".tab_list li.list_li"), $(".in  .tab_div"))
       k.pri()
   }
 TAB();

 

posted @ 2012-05-29 10:28  break_happy  Views(278)  Comments(0Edit  收藏  举报