title: Run Function for Every Div Class Individually
body: <p>My goal is is to insert the current day's hours for each business <code>&lt;div class="business"&gt;</code>, since this is becoming a more common feature of business listing sites to include "Today's Hours."</p>
  
  <p>So far, I'm able to show the hours for the first business div based on the current day. However, I'm unable to repeat the function for each <code>&lt;div class="business"&gt;</code>. The IDs within each business div are specific to that business, but I realize there are multiple of the same IDs throughout the HTML. </p>
  
  <p>I'm trying to isolate the code to run specifically for each <code>&lt;div class="business"&gt;</code> but it continues to only work on the first instance. I've read about .each() and so on, but nothing that seems to work for my particular situation. </p>
  
  <hr>
  
  <h2><strong>Here is my test HTML:</strong></h2>
  
  <pre><code>&lt;div class="business"&gt;
    &lt;h3&gt; Business One &lt;/h3&gt;
    &lt;p id="dayZero"&gt;Sunday Hours 1&lt;/p&gt;
    &lt;p id="dayOne"&gt;Monday Hours 1&lt;/p&gt;
    &lt;p id="dayTwo"&gt;Tuesday Hours 1&lt;/p&gt;
    &lt;p id="dayThree"&gt;Wednesday Hours 1&lt;/p&gt;
    &lt;p id="dayFour"&gt;Thursday Hours 1&lt;/p&gt;
    &lt;p id="dayFive"&gt;Friday Hours 1&lt;/p&gt;
    &lt;p id="daySix"&gt;Saturday Hours 1&lt;/p&gt;
    &lt;p style="color:red"&gt;Today's Hours: &lt;span id="currHours"&gt;&lt;/span&gt;&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;hr&gt;
  
  &lt;div class="business"&gt;
    &lt;h3&gt; Business Two &lt;/h3&gt;
    &lt;p id="dayZero"&gt;Sunday Hours 2&lt;/p&gt;
    &lt;p id="dayOne"&gt;Monday Hours 2&lt;/p&gt;
    &lt;p id="dayTwo"&gt;Tuesday Hours 2&lt;/p&gt;
    &lt;p id="dayThree"&gt;Wednesday Hours 2&lt;/p&gt;
    &lt;p id="dayFour"&gt;Thursday Hours 2&lt;/p&gt;
    &lt;p id="dayFive"&gt;Friday Hours 2&lt;/p&gt;
    &lt;p id="daySix"&gt;Saturday Hours 2&lt;/p&gt;
    &lt;p style="color:red"&gt;Today's Hours: &lt;span id="currHours"&gt;&lt;/span&gt;&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
  getCurrHours();
  &lt;/script&gt;
  </code></pre>
  
  <hr>
  
  <h2><strong>Here is my JavaScript:</strong></h2>
  
  <pre><code>function getCurrHours() {
  
    var dayZero = document.getElementById("dayZero").innerHTML;
    var dayOne = document.getElementById("dayOne").innerHTML;
    var dayTwo = document.getElementById("dayTwo").innerHTML;
    var dayThree = document.getElementById("dayThree").innerHTML;
    var dayFour = document.getElementById("dayFour").innerHTML;
    var dayFive = document.getElementById("dayFive").innerHTML;
    var daySix = document.getElementById("daySix").innerHTML;
  
    var currDay = getCurrDay();
  
    function getCurrDay() {
    switch (new Date().getDay()) {
        case 0:
            day = "Sunday";
            break;
        case 1:
            day = "Monday";
            break;
        case 2:
            day = "Tuesday";
            break;
        case 3:
            day = "Wednesday";
            break;
        case 4:
            day = "Thursday";
            break;
        case 5:
            day = "Friday";
            break;
        case 6:
            day = "Saturday";
        }
    return day;
    }
  
    var currHours = compareDays();
  
    function compareDays() {
      switch ( currDay ) {
        case "Sunday":
            hours = document.getElementById("currHours").innerHTML = dayZero;
            break;
        case "Monday":
            hours = document.getElementById("currHours").innerHTML = dayOne;
            break;
        case "Tuesday":
            hours = document.getElementById("currHours").innerHTML = dayTwo;
            break;
        case "Wednesday":
            hours = document.getElementById("currHours").innerHTML = dayThree;
            break;
        case "Thursday":
            hours = document.getElementById("currHours").innerHTML = dayFour;
            break;
        case "Friday":
            hours = document.getElementById("currHours").innerHTML = dayFive;
            break;
        case "Saturday":
            hours = document.getElementById("currHours").innerHTML = daySix;
        }
    return currHours;
    }
  
  }
  </code></pre>
  
  <hr>
  
  <h2><strong>Here is the JSFiddle: <a href="https://jsfiddle.net/jschaffranek/qp3ahLue/" rel="nofollow noreferrer">JSFiddle Example</a></strong></h2>