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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:49:49+00:00 2026-06-13T04:49:49+00:00

Below is my HTML. I’m at the <select> element, how do I get the

  • 0

Below is my HTML. I’m at the <select> element, how do I get the text from the next span element on the page? I’ve tried several things, including $( this ).nextAll( 'span:first' ).text(); where $( this ) is my select element, but I’m not getting the desire result.

<ul id="questions">
   <div>What do you want information about?</div>
   <li>
      <p>
         <select><!-- This is where I'm at. -->
            <option>Click to select...</option>
            <option data-next_select_name="foos">
               a foo
            </option>
            <option data-next_select_name="bars">
               a bar
            </option>
         </select>
      </p>
      <div>
         <a>
            <span>a foo</span><!-- I want the text out of this span. -->
            <div><b></b></div>
         </a>
         <div>
            <div><input type="text" /></div>
            <ul>
               <li>Click to select...</li>
               <li>
                  a foo
               </li>
               <li>
                  a bar
               </li>
            </ul>
         </div>
      </div>
      <p></p>
   </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-06-13T04:49:50+00:00Added an answer on June 13, 2026 at 4:49 am

    Just incase your html structure changes and .next() isn’t an option, I always prefer to go up to the definitive parent (in this case the list-item)

    $(this).closest('li')
           .find('span').first().text();
    

    Random side note: .first() is faster than :first

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

Sidebar

Related Questions

From below HTML code I want to get all the text except that in
I am using the below HTML file. The page displays nothing and my text
What is the best way to scrape the below HTML from a web page?
Whether it is possible to get the Text of a HTML <select> list instead
Conside below html - <div class=container1> <div class=container2> <div class=container3> <div class=container4> <div class=element>
I am getting a Value cannot be null error from the code below: @Html.Label(material.ExtendedGroup)
The HTML below will show a page with 2 buttons. One will open a
Does anyone know how to make a multiple select (see below HTML) sortable? Using
I have the below html markup <div class=title-wrap> <span class=title>Hello World</span> <br/> This title
Trying to grab the table ID from table id=1 in below html / script

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.