jQuery UI Accordion beforeActivate Event
Last Updated :
30 May, 2022
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 accordion beforeActivate event is used to trigger before an accordion panel is activated. The accordion beforeActivate event accepts two values that are listed below.
- event: It represents the event for the slider widget.
- ui: It is of an object type value. It contains four types of properties that are given below:
- newHeader: It represents the header that was just activated.
- oldHeader: It represents the header that was just deactivated.
- newPanel: It represents the panel that was just activated.
- oldPanel: It represents the panel that was just deactivated.
Syntax:
Initialize the accordion with the beforeActivate callback.
$( ".selector" ).accordion({
beforeActivate: function( event, ui ) {}
});
Bind an event listener to the accordionbeforeActivate event.
$( ".selector" ).on(
"accordionbeforeActivate",
function( event, ui ) {}
);
CDN Link: First, add jQuery UI scripts needed for your project.
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
Example: This example describes the uses of the jQuery UI Accordion beforeActivate event.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> jQuery UI Accordion beforeActivate Event </title>
<link rel="stylesheet" href=
"//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src=
"//code.jquery.com/jquery-1.12.4.js">
</script>
<script src=
"//code.jquery.com/ui/1.12.1/jquery-ui.js">
</script>
<style>
h1, h3 {
text-align: center;
}
#GFG {
width: 600px;
margin: 0 auto;
}
</style>
</head>
<body>
<h1 style="color:green;">
GeeksforGeeks
</h1>
<h3>jQuery UI Accordion beforeActivate Event</h3>
<div id="GFG">
<h3>HTML</h3>
<div>
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>
<h3>CSS</h3>
<div>
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>
<h3>JavaScript</h3>
<div>
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>
<h3>Bootstrap</h3>
<div>
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).
</div>
</div>
<script>
$(document).ready(function () {
$("#GFG").accordion();
$("#GFG").on("accordionbeforeactivate", function() {
alert("Accordion beforeActivate Event Triggered!");
});
});
</script>
</body>
</html>
Output:
Reference: https://api.jqueryui.com/accordion/#event-beforeActivate
Similar Reads
jQuery UI Accordion activate Event 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 selectmenu widget can provide us with select options. We can use this widget to make a form for different actions. The
3 min read
jQuery UI Accordion create Event 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 Accordion Widget can be used for the conversion of pairs of header & content panels into an accordion. The jQuery U
3 min read
jQuery UI Tabs beforeActivate Event 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. T
3 min read
jQuery UI Tabs activate Event 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. T
3 min read
jQueryUI Accordion active Option The accordion active option Indicates which index of the accordion menu is to be open when the page is accessed. By default, the value is 0, i.e. the first menu panel. Values: Boolean: When set to false will collapse all the panels.Integers: Zero-based index that sets which panel is to be active. Va
2 min read