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 6711857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:11:27+00:00 2026-05-26T08:11:27+00:00

I have multiple unordered lists with li’s in the form of a radio selection

  • 0

I have multiple unordered lists with li’s in the form of a radio selection display format. When I choose a subsequent li within an ul, I should be able to store the previously selected li and be able to access the text in the h3 above the ul until the next li is selected and it should go on in a similar fashion. Which selector of jQuery should I use? Any ideas on how to achieve this?

Usecase 1

<h3>text1</h3>
<ul id="one">
<li>some text</li>
<li>some text</li>
<li>some text</li>
</ul>
<h3>text2</h3>
<ul id="two">
<li>some text</li>
<li>some text</li> --> I select this li first.
<li>some text</li>
</ul>
<h3>text3</h3>
<ul id="third">
<li>some text</li>
<li>some text</li>
<li>some text</li> -> Next I select this li - at this point I should be able to get the text "text2" of the previously selected li and store it in a variable say var 1.
</ul>

Usecase 2

<h3>text1</h3>
<ul id="one">
<li>some text</li>
<li>some text</li>
<li>some text</li>
</ul>
<h3>text2</h3>
<ul id="two">
<li>some text</li>
<li>some text</li> --> I select this li first.
<li>some text</li> --> Next I select this li - at this point I should be able to get the text "text2" of the previously selected li and store it in the same variable as above ie var 1.
</ul>
<h3>text3</h3>
<ul id="third">
<li>some text</li>
<li>some text</li>
<li>some text</li> 
</ul>
  • 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-05-26T08:11:27+00:00Added an answer on May 26, 2026 at 8:11 am

    you can use the data object from jQuery

    var dataHolder = $('ul').first();
    
    dataHolder.data('oldEle', {
        text: 'NAN',
        index: -1,
        parentClass: "NANClass"
    });
    
    $('li').click(function() {
    
        alert('prev: ' + dataHolder.data('oldEle').text + ' index of prev: ' + dataHolder.data('oldEle').index + ' in parent: ' + dataHolder.data('oldEle').parentClass);
        dataHolder.data('oldEle').text = $(this).text();
        dataHolder.data('oldEle').index = $(this).index();
        dataHolder.data('oldEle').parentClass = $(this).closest('ul').attr('id');
    });
    

    data jquery example

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

Sidebar

Related Questions

Within multiple sections (accordion), I have a combination of paragraphs and unordered lists (dynamically
I have multiple unordered lists on my page. In each list, I want to
I have a multiple unordered lists, with a h2 titling each list by subject.
I'm new to jquery and I have a page with multiple unordered lists ul.
I'm trying to get multiple attributes from unordered lists from multiple divs that look
I have a few divs that contain unordered lists. Inside those list-items I have
I have three unordered lists each containing a subset of a group of items
I have a form with a checkbox (contained within a label #contact ). For
I have a newsletter application where a newsletter has multiple articles within each issue.
I have multiple list items in an unordered list. Each list item looks like

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.