title: How to use jquery and wp_enqueue_script
body: <p>I´ve spent a good while trying to figure this out. Im trying to add a script that need an external jquerylibrary. I can make it work by inserting my script between scripttags, however i understand thats not the correct way to do it, and it breaks another script on the site. </p>
  
  <p>I spent a fair amount of time tonight trying to figure out how to add the script correct, and i just cant get it. </p>
  
  <p>I understand something like this is the correct way to enqueue the script:</p>
  
  <p><code>function my_scripts_method() {
      wp_register_script( 'jquery', 'http://code.jquery.com/jquery-1.9.1.js');
      wp_enqueue_script( 'jquery' );
  }<br>
  add_action('wp_enqueue_scripts', 'my_scripts_method');
  </code></p>
  
  <p>My main question is, how do i write my functions so it calls the library, and at the same time failsafe it so it only loads once, and doesnt crash with other scripts? This is the script: </p>
  
  <pre><code>$(document).ready(function () {
  
  
  $("#menu-item-16").hover(
  
  
  
  
            function () {
                    $('body').css("background", "#ff9900");
                }, 
                function () {
                  $('body').css("background", "#ccc");
               }
              );
  
              $("#menu-item-17”).hover(
                function () {
                    $('body').css("background", "red");
                }, 
                function () {
                    $('body').css("background", "#ccc");
                }
              );
  
              $("#menu-item-18”).hover(
                function () {
                    $('body').css("background", "yellow");
                }, 
                function () {
                    $('body').css("background", "#ccc");
                }
              );
          });
  </code></pre>
  
  <p>Edit:</p>
  
  <p>Second question, several librarys and a stylesheet. </p>
  
  <p>As said above i have a little more complex script that you guys might be able to help me out. </p>
  
  <p>I have this code in the header right now, and it works. </p>
  
  <pre><code>   `&lt;link rel="stylesheet" type="text/css" href="/wp-content/themes/neighborhood/js/jquery.fullPage.css" /&gt;
  
      &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"&gt;     &lt;/script&gt; 
   &lt;script type="text/javascript" src="/wp-content/themes/neighborhood/js/vendors/jquery.slimscroll.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript" src="/wp-content/themes/neighborhood/js/jquery.fullPage.js"&gt;&lt;/script&gt;
  
  
  
  &lt;script&gt;
   $(document).ready(function() {
  $.fn.fullpage({
      verticalCentered: true,
       resize : true,
      slidesColor : ['#AF1700', '#359973', '#F46321', '#A6C7DB'],
      scrollingSpeed: 700,
      easing: 'easeInQuart',
      menu: false,
      navigation: false,
      navigationPosition: 'right',
      navigationTooltips: ['firstSlide', 'secondSlide'],
      slidesNavigation: true,
      slidesNavPosition: 'bottom',
      loopBottom: false,
      loopTop: false,
      loopHorizontal: true,
      autoScrolling: true,
      scrollOverflow: true,
      css3: false,
      paddingTop: '3em',
      paddingBottom: '10px',
      fixedElements: '#element1, .element2',
      normalScrollElements: '#element1, .element2',
      keyboardScrolling: true,
      touchSensitivity: 15,
      continuousVertical: false,
      animateAnchor: false, 
      setScrollingSpeed: 1000,
  
  
  
  });
  });    
  
   &lt;/script&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>From my newfound insights, i tried this, and it didnt work: </p>
  
  <p>`                </p>
  
  <pre><code>function fullpage() {     wp_enqueue_script('jquery');  
  </code></pre>
  
  <p>                              </p>
  
  <pre><code>wp_register_style( ’fullpage-css', get_template_directory_uri() . '/js/jquery.fullPage.css','','', 'screen' );   
  wp_register_script( 'jquery.1.8.3', get_template_directory_uri() . 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', array('jquery'),'',true  ); 
   wp_register_script( 'jquery.1.9.1', get_template_directory_uri() . 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js', array('jquery'),'',true  ); 
  </code></pre>
  
  <p>                   </p>
  
  <pre><code> wp_register_script( 'fullpage', get_template_directory_uri() . '/js/jquery.fullPage.js', array('jquery'),'',true  ); 
   wp_register_script( 'fullpagecode', get_template_directory_uri() . '/js/fullpagecode.js', array('jquery'),'',true  ); 
   wp_register_script( 'slimscroll', get_template_directory_uri() . '/js/vendors/jquery.slimscroll.min.js', '', null,''  ); 
  
  wp_enqueue_style( 'fullpage-css' ); // Enqueue our stylesheet
  </code></pre>
  
  <p>    </p>
  
  <pre><code>wp_enqueue_script( 'jquery.1.8.3' );  // Enqueue our first script
  </code></pre>
  
  <p> </p>
  
  <pre><code> wp_enqueue_script( 'jquery.1.9.1' ); // Enqueue our second script
  </code></pre>
  
  <p> </p>
  
  <pre><code> wp_enqueue_script( 'fullpage' );  // Enqueue our third  script
  </code></pre>
  
  <p>     </p>
  
  <pre><code>wp_enqueue_script( 'fullpagecode' ); // Enqueue fourth script
  </code></pre>
  
  <p>    </p>
  
  <pre><code> wp_enqueue_script( ’slimscroll’ ); // Enqueue fifth script
  </code></pre>
  
  <p>  </p>
  
  <pre><code>  }add_action( 'wp_enqueue_scripts', ’fullpage’ ); `
  </code></pre>