looking for a node after finding a specific node
<p>I am trying to save the html of a node to localstorage. Here is what I am trying to do. First look for the "strong" node and if the html of this node is "AM" only then will I get the time from the span node with class of "time". It seems to work but not the way I would like it to. Rather it gets the time string from the very first span rather than the span that is above the "strong" node with html of "AM". I hope this is clear if not I will try to explain as best I can.</p>

<p><strong>HTML</strong></p>

<pre><code>&lt;div&gt;
&lt;span class="time"&gt;Today 07:11 PM&lt;/span&gt;
&lt;strong&gt;PM&lt;/strong&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;span class="time"&gt;Today 07:21 PM&lt;/span&gt;
&lt;strong&gt;AM&lt;/strong&gt;
&lt;/div&gt;
</code></pre>

<p><strong>Code</strong></p>

<pre><code>checkTime = setInterval(function(){
    // get html of the 1st node
    var firstNode = $("strong").html();

    // if 1st node html is "AM" save time to local storage
    if (firstNode == "AM") {
      var userClock = $("span.time").html();
      localStorage.setItem('clock', userClock);
    }
}, 1000);
</code></pre>
