title: Changing properties of nth child in JavaScript
body: <p>I have a navigation bar where I change "background-image" of menu items with nth-of-type CSS selector. Now, I want to change the picture of "background-image" when I hover to a definitive menu item. So, how can I change the "background-image" when I hover over the menu iteam using Javascript?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"&gt;
          &lt;meta name="description" content=""&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
          &lt;title&gt;Islington College - Home&lt;/title&gt;
          &lt;link rel="stylesheet" href="css/style.css" type="text/css"&gt;
          &lt;style type="text/css"&gt;      
              nav ul li:nth-of-type(1){
                  background-image: url('images/navigation/active_home.png');
                  background-size: 40%;
                  background-repeat: no-repeat;
                  background-position: center top;
              }
              nav ul li:nth-of-type(2){
                  background-image: url('images/navigation/courses.png');
                  background-size: 40%;
                  background-repeat: no-repeat;
                  background-position: center top;
              }
              nav ul li:nth-of-type(3){
                  background-image: url('images/navigation/lectures.png');
                  background-size: 40%;
                  background-repeat: no-repeat;
                  background-position: center top;
              }
              nav ul li:nth-of-type(4){
                  background-image: url('images/navigation/admission.png');
                  background-size: 40%;
                  background-repeat: no-repeat;
                  background-position: center top;
              }
              nav ul li:nth-of-type(5){
                  background-image: url('images/navigation/facilities.png');
                  background-size: 40%;
                  background-repeat: no-repeat;
                  background-position: center top;
              }
              nav ul li:nth-of-type(6){
                  background-image: url('images/navigation/contact.png');
                  background-size: 40%;
                  background-repeat: no-repeat;
                  background-position: center top;
              }
          &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
       &lt;header class="main_header"&gt;
              &lt;figure id="logo"&gt;
                  &lt;img src="images/logo.png" alt="Islington College Logo"&gt;
              &lt;/figure&gt; 
              &lt;nav&gt;
                  &lt;ul&gt;
                      &lt;li&gt;&lt;a href="index.html" style="color: #EE2B32; padding-top: 43px;"&gt;Home&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="courses.html" style="padding-top: 40px;"&gt;Courses&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="lectures.html" style="padding-top: 40px;"&gt;Lectures&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="admission.html" style="padding-top: 34px;"&gt;Admission&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="facilities.html" style="padding-top: 38px;"&gt;Facilities&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="contact.html" style="padding-top: 41px;"&gt;Contact&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
              &lt;/nav&gt;
       &lt;/header&gt;</code></pre>
  </div>
  </div>
  </p>