/**
* @name Tabify
* @descripton Tabbed content with ease
* @version 1.4
* @requires Jquery 1.3.2
*
* @author Jan Jarfalk
* @author-email [email protected]
* @author-twitter janjarfalk
* @author-website http://www.unwrongest.com
*
* @licens MIT License - http://www.opensource.org/licenses/mit-license.php
*/(function($){ 
     $.fn.extend({  
         tabify: function( callback ) {
         
function getHref(el){
hash = $(el).find('a').attr('href');
hash = hash.substring(0,hash.length-4);
return hash;
}

  function setActive(el){
 
$(el).addClass('active');
$(getHref(el)).show();
$(el).siblings('li').each(function(){
$(this).removeClass('active');
$(getHref(this)).hide();
});
}

return this.each(function() {

var self = this;
var callbackArguments  = {'ul':$(self)};

$(this).find('li a').each(function(){
$(this).attr('href',$(this).attr('href') + '-tab');
});

function handleHash(){

if(location.hash && $(self).find('a[href=' + location.hash + ']').length > 0){
setActive($(self).find('a[href=' + location.hash + ']').parent());
}
}

if(location.hash){
handleHash();
}

setInterval(handleHash,100);

$(this).find('li').each(function(){
if($(this).hasClass('active')){
$(getHref(this)).show();
} else {
$(getHref(this)).hide();
}
});

if(callback){
callback(callbackArguments);
}

            }); 
        } 
    }); 
})(jQuery);
<script type="text/javascript">
// <![CDATA[

$(document).ready(function () {
$('#menu').tabify(); //调用
});

// ]]>
</script>
看了插件的代码完全没click的字样-  -应该怎么修改

解决方案 »

  1.   

    $(document).ready(function(e) {
    $("li").hover(function(e) {
    $(this).click()
    });
    });
    加了试试?不成就自己写一个呗,把这插件弄明白的时间不如写个自己满意的
      

  2.   

    个人感觉这个插件不怎么好用。不是事件行为,而是去辨识浏览器地址,再设置相应的tab,唯一的好处就是一个直达地址来访问的时候,可以动态的设置tab你说的找不到click就是这个原因,因为它根本不捕捉事件,而是在所有事件发生后进行的初始化。再一个使用setInterval也有点浪费资源。插件内又没看到什么UI渲染的部份,既然是固定的dom结构,自己写一个更简便