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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:15:38+00:00 2026-05-21T09:15:38+00:00

I am probably looking at this the wrong way, but I am having trouble

  • 0

I am probably looking at this the wrong way, but I am having trouble locating an element within my page and am hoping someone can help.

The scenario is this:
I have a <ul> containing a number of <li>'s which in turn contain <a href>'s. I am getting the value of the rel attribute of the clicked <a href> and want to replace the text in a <span class='someclass'> which is located in a parent container. There may be more than one of these <span class='someclass'> on the page so I need to find the closest one.

Here is how my HTML looks

<h3 class="my-header-class">
   <span class="some-class">Title Text</span>
 </h3>
 <ul class="tabs">
   <li><a rel="Title Text 1" href="#tab1">Link 1</a></li>
   <li><a rel="Title Text 2" href="#tab2">Link 2</a></li>
   <li><a rel="Title Text 3" href="#tab3">Link 3</a></li> 
 </ul>

Here is my javascript

 var titletext = $(this).attr('rel');
 var container = $(this).parent().children(".some-class");      
 container.text(titletext);

The titletext variable is being set with the correct text but I am unable to replace the text of the <span class='someclass'>. I assume because I am not finding it correctly.

Thanks,
Tristan

  • 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-21T09:15:39+00:00Added an answer on May 21, 2026 at 9:15 am
    $(this).parent().parent().prev().children(".some-class");
    
    
     <h3>     <!-- PREV OF UL -->
      <span>  <!-- CHILDREN OF H3 -->
    
     <ul>     <!-- PARENT OF <LI> AND <A> -->
      <li>    <!-- PARENT OF <A> AND CHILDREN OF <UL> -->
       <a>    <!-- CHILDREN OF <UL> AND <LI> -->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am probably looking for the wrong thing in the handbook, but I am
I could be looking at Enums in the wrong way but want to make
I'm working with MEF right now, but the answer I'm looking for probably is
I'm looking at a new computer which will probably have vista on it. But
Probably this question was already asked before, but my google-fu and SO-Search did not
MySQL CMD Client will run this file but get half way through and complain
this is probably a dumb question, but I couldnt find the answer I was
Having a hard time figuring out the best way to go about this. What
I'm struggling with understanding how Rake processes Cucumber tasks. I'm probably doing this wrong,
So, this one has me a little perplexed. I'm probably just looking at it

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.