Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
$(".accordion-btn").on("click", function() { const panel = $(this).next(".panel"); const isOpen = $(this).data("open") || false; panel.slideToggle(); $(this).data("open", !isOpen) .text(isOpen ? "Show more" : "Show less"); });
Result
Open