Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1338818

    kateanita
    Participant

    Hello,

    I’m using the Visual Composer accordion and was wondering if there is a way to have the “Read More” words change to “Read Less” when the accordion is opened.

    Here is the page I’m working on: http://homefed.stapkodesign.com/

    Everything I have is the latest version.

    Thanks!

    Katie

    #1339097

    Rue Nel
    Moderator

    Hello Katie,

    Thanks for writing in! To resolve your issue, please add the following JS code in the customizer, Appearance > Customize > Custom > Javascript

    (function($){
      $('#page-id-8 #x-content-band-1 .x-accordion-toggle').on('click touchend', function(){
        if( ! $(this).hasClass('collapsed') ) {
          $(this).text('Read More');
        } else {
          $(this).text('Read Less');
        }
      })
    })(jQuery);

    We would loved to know if this has work for you. Thank you.

    #1342200

    kateanita
    Participant

    Thanks for the response! Unfortunately that didn’t work… 🙁

    #1342232

    Nico
    Moderator

    Hi There,

    Please try this code below:

    jQuery(document).ready(function( $ ) {
    $('#x-content-band-1 .x-accordion-toggle').click(function(event){
        var item = $(this);
         if(item.hasClass('collapsed')) {item.html('Read Less');
    	 }
        else {
             item.html('Read More');
        }
       });
    });

    Let us know how it goes.

    Thanks.

    #1343797

    kateanita
    Participant

    That worked perfectly! You guys are awesome, thanks so much!

    #1344061

    Nico
    Moderator

    Happy to hear that.

    Feel free to ask us again.

    Thanks.