Slide Effects for Tabs

2019-08-18 03:00发布

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?

2条回答
Viruses.
2楼-- · 2019-08-18 03:18

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" );
   });
 });
查看更多
太酷不给撩
3楼-- · 2019-08-18 03:24
 $(document).ready(function(){
     $('#tabs').click(function(){
       $(this).tabs();
     });
 });
查看更多
登录 后发表回答