Title: Adding javascript actions to tab clicks
Last modified: August 12, 2018

---

# Adding javascript actions to tab clicks

 *  Resolved [dahollings](https://wordpress.org/support/users/dahollings/)
 * (@dahollings)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/adding-javascript-actions-to-tab-clicks/)
 * 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](https://wordpress.org/support/users/numeeja/)
 * (@numeeja)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/adding-javascript-actions-to-tab-clicks/#post-10583806)
 * 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](https://wordpress.org/support/users/dahollings/)
 * (@dahollings)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/adding-javascript-actions-to-tab-clicks/#post-10586127)
 * 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.

 * ![](https://ps.w.org/tabby-responsive-tabs/assets/icon-256x256.jpg?rev=2682041)
 * [Tabby Responsive Tabs](https://wordpress.org/plugins/tabby-responsive-tabs/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tabby-responsive-tabs/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tabby-responsive-tabs/)
 * [Active Topics](https://wordpress.org/support/plugin/tabby-responsive-tabs/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tabby-responsive-tabs/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tabby-responsive-tabs/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [loading](https://wordpress.org/support/topic-tag/loading/)

 * 2 replies
 * 2 participants
 * Last reply from: [dahollings](https://wordpress.org/support/users/dahollings/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/adding-javascript-actions-to-tab-clicks/#post-10586127)
 * Status: resolved