EduardET

show/hide section change button text

Nov 15th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ( function( $ ) {
  2.     $( document ).ready( function() {
  3.         var button = $( ".show-more-content" );
  4.         button.click( function( e ) {
  5.             e.preventDefault();
  6.             var section = $( this ).data( "section" );
  7.             if ( $( "." + section ).hasClass( "wpc-visible" ) ) {
  8.                 $( "." + section ).removeClass( "wpc-visible" ).slideUp();
  9.                 $( this ).text( "Show more content" );
  10.             } else {
  11.                 $( "." + section ).slideDown().addClass( "wpc-visible" );
  12.                 $( this ).text( "Hide content" );
  13.             }
  14.         } )
  15.     } );
  16. } )( jQuery );
Advertisement
Add Comment
Please, Sign In to add comment