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

  • Home
  • SEARCH
  • 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 8060197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:54:41+00:00 2026-06-05T09:54:41+00:00

I have this container: <Div id=ListContainer> I append these data to it : ‘

  • 0

I have this container:

  <Div id="ListContainer">

I append these data to it :

 ' <a class="lesson" subjectID="'+sbj_ID+'"><b>
  <span class="lesson_subject">' + sbj_Name + '</span></b></a> ';

I want to put the value of sbj_ID & sbj_Name in a variable.

    localStorage['SubjectID']= "value of sbj_ID";
    localStorage['SubjectName']="value of sbj_Name";

But I can’t access them.

I tried :

     $('#ListContainer').find('.lesson').attr('subjectID')
     $('#ListContainer .lesson').children[0].getAttribute('SubjectID')
     $('#ListContainer .lesson').children[2].innerHTML;

But they didn’t work.

  • 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-05T09:54:42+00:00Added an answer on June 5, 2026 at 9:54 am

    I don’t know how you are appending the string, but the following is a working example:

    var sbj_ID = 3;
    var sbj_Name = "test";
    
    var str = '<a class="lesson" subjectID="'+sbj_ID+'"><b><span class="lesson_subject">' + sbj_Name + '</span></b></a>';
    
    $("#ListContainer").append(str);
    
    alert($('#ListContainer').find('.lesson').attr('subjectID'));
    

    — See Demo —

    I’m also not sure how LocalStorage is being used, but you should set the variables as the value, not the strings you have used:

    localStorage['SubjectID']= sbj_ID;
    localStorage['SubjectName']= sbj_Name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code for my top.phtml file <div class=header-nav-container> <div class=header-nav> <h4 class=no-display><?php
i have this html code <div class=container id=container> <div class=post><h1>first title</h1>description here</div> <div class=post><h1>second
I have this jQuery and HTML http://jsfiddle.net/UgX3u/30/ <div class=container> <div class=yellow></div> <div class=red></div> <div
I have this simplified code: <div class=container> <input type=submit name=submit class=submit value=Sign Up> </div>
I have this code: <div class=container id=container> <div class=content id=content> <div class='nav'> <ul> <li><a
Say I have this: <div class='container'> <img src='image1' id='1' /> <img src='image2' id='2' />
I have this HTML : HTML : <div class=stave-container> <section id=Captcha></section> <div id=horiz_container_outer> <img
I have this container div whose width I would like to set according to
I have a container (div) with a background image. In this div there is
I want to have 3 divs aligned inside a container div, something like this:

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.