-
AuthorPosts
-
March 22, 2015 at 8:17 pm #233069
Hi Guys,
May I please ask you how I can attach some JavaScript code to the buttons that are built into the theme?
Thanks,
Peter
March 23, 2015 at 2:07 am #233215Hello Peter,
Thanks for posting in!
The safest way to do it is by adding an “id” in your button. If you are using a shortcode, it should look like this,
[button id="my-button" shape="square" size="mini" float="none" info="none" info_place="top" info_trigger="hover"]this is the button[/button]
. And if you are using a visual composer, you can add the id by editing you button settings just like this, http://prntscr.com/6k8lx4Once you have your button id setup, you can use the custom javascript section from the customizer, Appearance > Customize > Custom > Javascript to insert your code. You can easily attach your custom javascript script to the button like this code:
jQuery('#my-button').click( function(){ // do something here });
Hope this helps.
March 23, 2015 at 10:42 am #233448Yes, it’s very helpful, thanks so much 🙂
March 23, 2015 at 12:33 pm #233510You’re most welcome!
Let us know if you need anything else.
Cheers!
-
AuthorPosts