1(function ($){ 2 $(document).ready(function() { 3 // Top-level element to easily capture each dropdown and its children 4 const elements = $('.ghostkit-accordion-item'), 5 6 // The actual dropdowns that need the aria-expanded attribute 7 dropdowns = []; 8 9 if (elements.length === 0) { 10 return; 11 } 12 13 // Initialize aria-expanded to false for each dropdown and store the dropdown elements 14 elements.each(function() { 15 const dropdown = $(this).find('a'); 16 dropdowns.push(dropdown); 17 dropdown.attr('aria-expanded', 'false'); 18 }); 19 20 // Add click event listeners to each top-level element to toggle aria-expanded and close other dropdowns 21 for (let i = 0; i < elements.length; i++) { 22 $(elements[i]).on('click', function () { 23 const isExpanded = dropdowns[i].attr('aria-expanded') === 'true'; 24 dropdowns[i].attr('aria-expanded', !isExpanded); 25 26 for (let j = 0; j < elements.length; j++) { 27 if (i === j) { 28 continue; 29 } 30 31 dropdowns[j].attr('aria-expanded', 'false'); 32 } 33 }); 34 } 35 }); 36})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.