Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7892485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:52:56+00:00 2026-06-03T06:52:56+00:00

I am trying to save the html of a node to localstorage. Here is

  • 0

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.

HTML

<div>
<span class="time">Today 07:11 PM</span>
<strong>PM</strong>
</div>

<div>
<span class="time">Today 07:21 PM</span>
<strong>AM</strong>
</div>

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);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:52:58+00:00Added an answer on June 3, 2026 at 6:52 am
    checkTime = setInterval(function(){
        // get html of the 1st node
        var firstNode = $('strong:contains("AM")');
    
        // if 1st node html is "AM" save time to local storage
          var userClock = firstNode.prev('span.time').html();
          localStorage.setItem('clock', userClock);
    }, 1000);
    

    Live Proof

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to save html table to sql server table with unique name
Im trying to save a simple script in netbeans to htdocs, but i only
I'm trying to save some UserControl-Infos into a List like this: List<UserControlDetails> myList; public
hey guys im trying to save a url link in a html form but
I'm basically trying to setup my own private pastebin where I can save html
I'm trying to log in to a website and save an HTML page automatically
I'm trying to save contents of a div to new html file. I'm using
I'm trying to save dynamic html so that on a failed validation in asp.
Im trying to implement a save feature to save an html file. Currently it
I'm trying to save a snapshot of an html page. I'm quite satisfied with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.