Advertisement
MaewRS

[JS] FAQs Accordion with switching icon

Dec 2nd, 2020
878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $( document ).ready(function() {
  2.     /*Accordion*/
  3.     let icon = '<i class="fas fa-chevron-circle-down"></i>';
  4.  
  5.     $( ".faq-item .panel-title a" ).each(function() {
  6.         let phead = $(this).html();
  7.         $(this).html(phead+icon);
  8.  
  9.     });
  10.  
  11.     $('.collapse').on('shown.bs.collapse', function(){
  12.     $(this).parent().find(".fas").removeClass("fa-chevron-circle-down").addClass("fa-chevron-circle-up");
  13.     }).on('hidden.bs.collapse', function(){
  14.     $(this).parent().find(".fas").removeClass("fa-chevron-circle-up").addClass("fa-chevron-circle-down");
  15.     });
  16.  
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement