• Hey guys,

    Can you help me change the js script a bit. Once a user opens a question and reads it and then decides to open another question, the previous one should close (close the parent question). How can I do that?

    Here is the js code:

    $(function() {
            $('.qe-toggle-title').click(function () {
                var parent_toggle = $(this).closest('.qe-faq-toggle');
                if ( parent_toggle.hasClass( 'active' ) ) {
                    $(this).find('i.fa').removeClass( 'fa-minus-circle' ).addClass( 'fa-plus-circle' );
                    parent_toggle.removeClass( 'active' ).find( '.qe-toggle-content' ).slideUp( 'fast' );
                } else {
                    $(this).find('i.fa').removeClass( 'fa-plus-circle' ).addClass( 'fa-minus-circle' );
                    parent_toggle.addClass( 'active' ).find( '.qe-toggle-content' ).slideDown( 'fast' );
                }
            });
        });

    Thank you for your help

Viewing 1 replies (of 1 total)
  • Replace above code with

    $(".qe-toggle-title").click(function () {
    		if ($('.qe-toggle-content').is(':visible')) {
    		  $(".qe-toggle-content").slideUp(100);
    		  $('.qe-toggle-title').find('i.fa').removeClass( 'fa-minus-circle' ).addClass( 'fa-plus-circle' );
    		}
    		if ($(this).next(".qe-toggle-content").is(':visible')) {
    		        $(this).next(".qe-toggle-content").slideUp(100);
    		        $(this).find('i.fa').removeClass( 'fa-minus-circle' ).addClass( 'fa-plus-circle' );
    		} else {
    		       $(this).next(".qe-toggle-content").slideDown(100);
    		       $(this).find('i.fa').removeClass('fa-plus-circle').addClass('fa-minus-circle');
    	       }
             });
    • This reply was modified 7 years, 5 months ago by nilesh6018.
    • This reply was modified 7 years, 5 months ago by nilesh6018.
    • This reply was modified 7 years, 5 months ago by nilesh6018.
Viewing 1 replies (of 1 total)
  • The topic ‘Make question close when opening another one’ is closed to new replies.