Skip to content
Related Articles

Related Articles

jQuery UI Tabs beforeActivate Event

View Discussion
Improve Article
Save Article
  • Last Updated : 01 Jun, 2022
View Discussion
Improve Article
Save Article

jQuery UI consists of GUI widgets, visual effects, and themes implemented using HTML, CSS, and jQuery. jQuery UI is great for building UI interfaces for the webpages. The jQuery UI Tabs widget is used to create a single content area with multiple panels that are associated with a header in a list.

The jQuery UI Tabs beforeActivate event is used to trigger when the tab is going to be active.

The Tabs beforeActivate event accepts 2 values that are listed below:

  • event: It represents the event for the tabs widget.
  • ui: It is of an object type, and contains the following values:
    • newTab: It represents the tab that is about to be activated.
    • oldTab: It represents the tab that is about to be deactivated.
    • newPanel: It represents the panel that is about to be activated.
    • oldPanel: It represents the panel that is about to be deactivated.


Initialize the tabs with the create callback:

$( ".selector" ).tabs({
      beforeActivate: function( event, ui ) {}

Bind an event listener to the tabsbeforeactivate event:

$( ".selector" ).on( 
    function( event, ui ) {} 

CDN Link: First, add jQuery UI scripts needed for your project.

<link rel=”stylesheet” href=”//”>
<script src=”//”></script>
<script src=”//”></script>

Example: This example describes the uses of the jQuery UI Tabs beforeActivate event.


<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
        jQuery UI Tabs beforeActivate Event
    <link rel="stylesheet"
    <script src="//">
    <script src="//">
        #gfg {
            width: 600px;
            text-align: justify;
    <h1 style="color: green;">
    <h3>jQuery UI Tabs beforeActivate Event</h3>
    <div id="gfg">
            <li><a href="#gfg1">HTML</a></li>
            <li><a href="#gfg2">CSS</a></li>
            <li><a href="#gfg3">JavaScript</a></li>
            <li><a href="#gfg4">Bootstrap</a></li>
        <div id="gfg1">
            HTML stands for HyperText Markup Language. 
            It is used to design web pages using the 
            markup language. HTML is the combination 
            of Hypertext and Markup language. Hypertext 
            defines the link between the web pages and
            markup language defines the text document 
            within the tag that define the structure 
            of web pages.
        <div id="gfg2">
            CSS (Cascading Style Sheets) is a stylesheet 
            language used to design a webpage to make it 
            attractive. The reason for using this is to 
            simplify the process of making web pages 
            presentable. It allows you to apply styles 
            on web pages. More importantly, it enables 
            you to do this independent of the HTML that 
            makes up each web page.
        <div id="gfg3">
            JavaScript is the world most popular 
            lightweight, interpreted compiled programming 
            language. It is also known as scripting 
            language for web pages. It is well-known for 
            the development of web pages, many non-browser 
            environments also use it. JavaScript can be 
            used for Client-side developments as well as 
            Server-side developments.
        <div id="gfg4">
            Bootstrap is a free and open-source tool 
            collection for creating responsive websites 
            and web applications. It is the most popular 
            HTML, CSS, and JavaScript framework for 
            developing responsive, mobile-first websites. 
            Nowadays, the websites are perfect for all 
            the browsers (IE, Firefox, and Chrome) and 
            for all sizes of screens (Desktop, Tablets, 
            Phablets, and Phones).
        $(document).ready(function () {
            $("#gfg").on('tabsbeforeactivate', function () {
                alert("Tabs beforeActivate Event Triggered!");




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!