Support » Fixing WordPress » jquery – not working & where to place the js code

  • Ok, I’m driving myself nuts with jquery. I’ve read so much, visited the forms, and tried so many methods I feel like I’m running in circles.

    Since I can’t find what I’m looking for, this may become a good tutorial for those experiencing similar issues. I’ll start from scratch:

    I want to be able to use javacript files within my web pages. I don’t have a blog; instead I have a web site. I use “Filezilla” and “Mozilla Firefox with Firebug 1.9.1.”

    The only way I can get javascript to work is to enter the code within my individual page editor. Since nothing works, I’ve decided go back to the basics. This code was taken right out of “” and pasted into my web page. It’s simply a button that, when clicked on, hides a paragraph with an ID of “test.” I also installed & activated the “Use Google Libraries” plugin.

    Here’s the code (& yes I know this should not be entered within the page code; I just don’t know what to do next – the right way):

    <script type='text/javascript' src=''></script>
    <script type="text/javascript" src="jquery.js">
    </script><script type="text/javascript">
    <h2>This is a heading</h2>
    <p>This is a paragraph.</p>
    <p id="test">This is another paragraph.</p>
    <button>Click me</button>

    Within the Header.php file, and just before the “wp_head();” I’ve entered this one line of code:

    Also, within the “functions.php” file I’ve entered:

    wp_enqueue_script( 'onLoad', '/wp-content/themes/a-simple-love/jquery/jquery.js', array( 'jquery' ) );
    function add_google_jquery() {
       if ( !is_admin() ) {
          wp_register_script('jquery', '', false);

    With that said, what should I do next and where (if not within the page editor) should I place the javascript code?

    Thx in advance for helping me get out of this never-ending circle. I hope it will be helpful to others as well.

Viewing 1 replies (of 1 total)
  • in your functions.php

    aadd_action('init', 'hide');
    function hide() {
    	if (!is_admin()) {
    		// register your script location, dependencies and version
    			get_stylesheet_directory_uri() . '/js/hide.js',
    			array('jquery') );
       // enqueue the script
Viewing 1 replies (of 1 total)
  • The topic ‘jquery – not working & where to place the js code’ is closed to new replies.