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

The Archive Base Latest Questions

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

I am somewhat new to jquery and have no idea if this is possible,

  • 0

I am somewhat new to jquery and have no idea if this is possible, so here goes.

Basically, I am using an ajax get request, the result is in valid html, I already can select a specific object on the page that I want, and I want to then use that to get all of its siblings, this is how the code looks:

$.ajax(
    {
        type: 'GET',
        url: requestUrl,
        dataType: 'html',
        success: function(data, textStatus)
        {
            var allLinks = $(data).find("a");
            allLinks.each(function(){
                        if($(this).text() == 'selectme'){
                             $(this).parent().children("a").last().css('color', 'red');
                        }
                    });
              }
      });

This is what the response looks like:

<html>
<body>
   <a>irrelevant link 1</a>
   <div>
      <a>selectme</a>
      <a>sibling 1</a>
      <a>sibling 2</a>
      <a>last sibling, which I want to get</a>
   </div>
   <a>irrelevant link 2</a>
   <a>irrelevant link 3</a>
</body>
</html>

So, basically, I want to get the last sibling of the selectme link. Is it possible to make parent use the response instead of the actual page elements, and if not, how can I get the siblings without getting any of the irrelevant links? I could use the index of “selectme” to create a subselection, but how can I stop before “irrelevant link 2”?

  • 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:15:05+00:00Added an answer on May 26, 2026 at 8:15 am

    Have you try to add the response to the HTML document.

    $.ajax(
    {
        type: 'GET',
        url: requestUrl,
        dataType: 'html',
        success: function(data, textStatus)
        {
            $('body').html(data); // jQuery works on actual DOM, not just a string
            var allLinks = $('body').find("a");
            allLinks.each(function(){
                        if($(this).text() == 'selectme'){
                             $(this).parent().children("a").last().css('color', 'red');
                        }
                    });
              }
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have somewhat of a thought question regarding jQuery Ajax. My question is this:
I'm somewhat new to Ajax/Jquery, so I apologize if this is an easy question,
I am somewhat new to jQuery and I have a problem with something I
I am somewhat new to Jquery but I feel complete failure here at not
I am somewhat new to jQuery but have been having fun trying learn about
I'm extremely new to using jQuery/JavaScript, so please don't judge me if this is
I am having some trouble setting up FancyBox, I am somewhat new to jQuery.
I am somewhat new to PHP and am running into an issue. Here is
I am somewhat new to android development and development in general. I have a
I am somewhat new to LINQ and have a quick question regarding deleting. Say,

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.