Slide Effects for Tabs

China☆狼群 提交于 2019-12-25 06:37:05

问题


I'm trying to make a slide effect between tabs. Here is the jQuery code:

$(document).ready(function(){
   $('#tabs').tabs();
});

$(document).click(function() {
   $( "#tabs" ).effect( "slide", "medium" );
});

This works but it works if you click anywhere on the page. I want it to work only when you click that tab. I know its because I have to get rid of the "document" from the click function. I've tried replacing "document" with #tabs, #tabs .ui-tabs-nav ul, #tabs .ui-tabs-nav li. What do I put in there for the click function?


回答1:


Try this ..

  $(document).ready(function(){
   $('#tabs').tabs();

   $("#tabs").click(function() {
         $(this).effect( "slide", "medium" );
     });
 });

--- Or for tab anchor click :

 $(document).ready(function(){
    $('#tabs').tabs();

   $("#tabs a").click(function() {
        $('#tabs').effect( "slide", "medium" );
   });
 });



回答2:


 $(document).ready(function(){
     $('#tabs').click(function(){
       $(this).tabs();
     });
 });


来源:https://stackoverflow.com/questions/22215679/slide-effects-for-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!