Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- ( function( $ ) {
- $( document ).ready( function() {
- var person_module = $( '.wpc-person' ),
- list_id = [],
- fun_facts_section = $( '.fun-facts' );
- function get_person_title( el ) {
- var person_index = el.parent().index(),
- person_name = el.find( '.et_pb_module_header' ).text().replace( /\s+/g, '-' ).toLowerCase();
- list_id.push( person_name );
- }
- //Insert into list_id title each person name
- person_module.each( function() {
- get_person_title( $( this ) )
- } )
- //asign the css id for each Fun Fact section based on the Person Name
- fun_facts_section.each( function() {
- console.log( $( this ).index() - 1 );
- $( this ).attr( 'id', list_id[ $( this ).index() - 1 ] );
- } )
- person_module.each( function() {
- $( this ).click( function() {
- var person_name = $( this ).find( '.et_pb_module_header' ).text().replace( /\s+/g, '-' ).toLowerCase();
- $( '.fun-facts' ).removeClass( 'show-fact' ).addClass( 'hide-fact' );
- $( '#' + person_name ).removeClass( 'hide-fact' ).addClass( 'show-fact' );
- } )
- } )
- } );
- } )( jQuery );
- </script>
Advertisement
Add Comment
Please, Sign In to add comment