This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Adding some basic javascript

Resolved 3 replies premiumthemetheme-vantage
11 years ago · Last reply by Andrew Misplon 11 years ago

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.

Need fast email support? Get SiteOrigin Premium

Replies

3
  1. Andrew Misplon Staff 11 years, 3 months ago

    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. Tim Smit 11 years, 3 months ago

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

    Thx

  3. Andrew Misplon Staff 11 years, 3 months ago

    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.

Have a different question or issue?

Start New Thread