Home>Support>Adding some basic javascript

Adding some basic javascript

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.

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 9 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    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/

  2. 9 years, 10 months ago Tim Smit

    Made it.. Small fault im my js as well. But the enqueue works.

    Thx

  3. 9 years, 10 months ago Andrew Misplon
    Hi, I Work Here

    Super, glad that did the trick.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More