jQuery - trapping tab select event

前端 未结 7 1987
予麋鹿
予麋鹿 2020-12-03 04:50

I\'m a jQuery noob and I\'m trying to figure out how to trap the tab selected event. Using jQuery 1.2.3 and corresponding jQuery UI tabs (not my choice and I have no control

7条回答
  •  暖寄归人
    2020-12-03 04:58

    This post shows a complete working HTML file as an example of triggering code to run when a tab is clicked. The .on() method is now the way that jQuery suggests that you handle events.

    jQuery development history

    To make something happen when the user clicks a tab can be done by giving the list element an id.

  • Then referring to the id.

    $("#list").on("click", function() {
     alert("Tab Clicked!");
    });
    

    Make sure that you are using a current version of the jQuery api. Referencing the jQuery api from Google, you can get the link here:

    https://developers.google.com/speed/libraries/devguide#jquery

    Here is a complete working copy of a tabbed page that triggers an alert when the horizontal tab 1 is clicked.

    
    
    
    
    
    TabDemo
    
    
    
    
    
    
    
    
    
    
    
    
    

    jQuery UI Tabs Styling

    Nested tabs, horizontal then vertical.

    Nested Left Two

    Nested Left Three

    Tab Two Main

    Tab Three Main

提交回复
热议问题