Hello,
I’m new to using javascript and jquery. And I want to test it out on my website. I’m runnign Vantage theme Premium.
I’ve been trying to add the js, but so far it’s not working yet. Not sure if I’ve added it wrong or my jQuery skills are bad.
I’ve added an image on my homepage in the page builder lay out.
I’ve given the image the following id. And added it in the css.
#computerwp { }
Here is my js.
jQuery(function($){ $('#computerwp').click(function(){ $('#this').hide(); }; });
I want the image to dissapear on the click. It’s just for trying out if it works. What is the correct way of adding the js?
Hoping for some help.
Hi Tim
The correct way would be to enqueue your JS in the functions file of a child theme:
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
http://www.wpbeginner.com/wp-tutorials/how-to-properly-add-javascripts-and-styles-in-wordpress/
A quicker way for testing might be to use a plugin like this: https://wordpress.org/plugins/header-and-footer-scripts/
Made it.. Small fault im my js as well. But the enqueue works.
Thx
Super, glad that did the trick.