jQuery UI consta de widgets GUI, efectos visuales y temas implementados mediante HTML, CSS y jQuery. jQuery UI es excelente para crear interfaces de interfaz de usuario para las páginas web. El jQuery UI Accordion Widget se puede usar para convertir pares de paneles de encabezado y contenido en un acordeón.
El evento jQuery UI Accordion create se usa para desenstringr cuando se crea el acordeón. Si un widget de acordeón está contraído, ui.header y ui.panel serán objetos vacíos. El evento de creación de acordeón acepta 2 valores que se enumeran a continuación:
- evento: Representa el evento para el control deslizante.
- ui: es de tipo objeto y contiene los siguientes valores:
- header: Representa la cabecera activa.
- panel: Representa el panel activo.
Sintaxis:
- Inicialice el acordeón con la devolución de llamada de creación:
$( ".selector" ).accordion({ create: function( event, ui ) {} });
- Vincule un detector de eventos al evento accordioncreate:
$( ".selector" ).on( "accordioncreate", function( event, ui ) {} );
Enlace CDN: Primero, agregue los scripts jQuery UI necesarios para su proyecto.
<link href=”https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css”
rel=”stylesheet”>
<script src=”https://code. jquery.com/jquery-1.10.2.js”></script>
<script src=”https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>
Ejemplo: Este ejemplo describe la implementación del evento jQuery UI Accordion create.
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title> jQuery UI Accordion create Event </title> <link href= "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet"> <script src= "https://code.jquery.com/jquery-1.10.2.js"> </script> <script src= "https://code.jquery.com/ui/1.10.4/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 create 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").on("accordioncreate", function() { alert("Accordion Create Event Triggered!"); }); $("#GFG").accordion(); }); </script> </body> </html>
Producción:
Referencia: https://api.jqueryui.com/accordion/#event-create
Publicación traducida automáticamente
Artículo escrito por blalverma92 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA