开发者

Using the select on jquery tabs?

开发者 https://www.devze.com 2022-12-27 04:56 出处:网络
Hi I want to perform a task when I click a specific tab, let\'s say #tab-2. how is that done? I don\'t understand the documentation 开发者_如何学运维on the jquery site.

Hi I want to perform a task when I click a specific tab, let's say #tab-2. how is that done? I don't understand the documentation 开发者_如何学运维on the jquery site.

I know how it's done on all tabs but not just one


You can do it like this, just check the tab ID:

$( ".selector" ).tabs({
   select: function(event, ui) {
     if(ui.tab.href == "#tab-2") { // or ui.panel.id == "tab-2"
       //do something...
     }
   }
});

You can see what all elements are available on the passed ui argument here, ui.tab is the selected tab link (the <a>), ui.panel is the selected tab itself (the <div>).


like this:

$("#tab-2").click(function() {
 //do something
});

?

0

精彩评论

暂无评论...
验证码 换一张
取 消