• Resolved dahollings

    (@dahollings)


    Hello,

    Is it possible to add javascript actions when clicking on individual tabs? I am having trouble displaying maps and some photo galleries in the tabs because they are loading with 0 height and then not displaying. I think this could be fixed by executing a $(window).resize(); when the tab is clicked but I have not been able to get this working so far.

    Thanks,
    -Dave

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author cubecolour

    (@numeeja)

    This would need custom code added.

    Something like this might help:

    
    function cc_tabtrigger() {
    
    	wp_enqueue_script( 'jquery' );
    
    	echo '<script type="text/javascript">
    	jQuery(function($){
    
    		$("body").on("click", "#tablist1-tab1, .responsive-tabs__heading:nth-of-type(1)", function() {
    			alert("Tab 1 Clicked");
    		});
    
    		$("body").on("click", "#tablist1-tab2, .responsive-tabs__heading:nth-of-type(2)", function() {
    			alert("Tab 2 Clicked");
    		});
    
    		$("body").on("click", "#tablist1-tab3, .responsive-tabs__heading:nth-of-type(3)", function() {
    			alert("Tab 3 Clicked");
    		});
    
    	});</script>';
    }
    
    add_action( 'wp_head', 'cc_tabtrigger', 100 );
    
    Thread Starter dahollings

    (@dahollings)

    This appears to be working great! Thank you so much for the help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding javascript actions to tab clicks’ is closed to new replies.