title: Add Javascript in Wordpress - functions.php with wp_enqueue_script()
body: <p>I want to add my custom javascript to my wordpress page. </p>
  
  <p>I tried it usign <code>wp_enqueue_script()</code> but its not working. When I tried to add script directly in Inspect element it works properly so my script is correct. </p>
  
  <p>Now I create function in <code>function.php</code> file to add script and its not working. It shows script / file is loaded in page when I check source of page. But it doing nothing. </p>
  
  <p>Below is my script and function. </p>
  
  <p>Javascript -</p>
  
  <pre><code>jQuery(".tp-tab").mouseenter(function() {
    jQuery('.tp-tab').removeClass("selected");
  });
  jQuery(".tp-tab").click(function() {
    jQuery(this).addClass("selected");
  });
  </code></pre>
  
  <p>Function in function.php </p>
  
  <pre><code>    function mytheme_custom_scripts() {
  
              if ( !is_admin() ) {
                  $scriptsrc = get_stylesheet_directory_uri() . '/wp-content/themes/circles/js/';
                  wp_register_script( 'myhandle', $scriptsrc . 'slider_hover_effect.js', 'jquery', '1.0',  false );
                  wp_enqueue_script( 'myhandle' );
              }
  
          }
  
  add_action( 'wp_enqueue_scripts', 'mytheme_custom_scripts' );
  </code></pre>
  
  <p>In <code>/wp-content/themes/circles/js/</code> directory location my script is palced with file name of <code>slider_hover_effect.js</code> which contain above javascript code. </p>
  
  <p>Please let me know is there any other way I can add this script in my wordpress website. Also I want to add/apply this script only for Homepage. So is this possible. </p>
  
  <p>Thanks, </p>
  
  <h2>Update</h2>
  
  <p>I am not sure about that I should provide complete path after <code>get_stylesheet_directory_uri()</code> or just <code>/js/</code> folder. </p>
  
  <p>Or </p>
  
  <p>Can I use like -</p>
  
  <pre><code>function slider_effect() { ?&gt;
      &lt;script type="text/javascript"&gt;
  
  jQuery(".tp-tab").mouseenter(function() {
    jQuery('.tp-tab').removeClass("selected");
  });
  jQuery(".tp-tab").click(function() {
    jQuery(this).addClass("selected");
  });
  
      &lt;/script&gt;
  
      &lt;?php
  
  }
  
  add_action('wp_head','slider_effect');
  </code></pre>