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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:47:34+00:00 2026-05-23T23:47:34+00:00

I am using .each() to iterate over the links in the jQuery object $firstParagraph

  • 0

I am using .each() to iterate over the links in the jQuery object $firstParagraph. As I iterate over the links, I would like to refer to them in an absolute way, without calling $(this) which creates a new object each time it is called. Because when I iterate twice independently over the links (as shown in the code below), then the work done in both instances is not combined.

$firstParagraph = $("p").eq(0);

// Iterate over the links once
$firstParagraph.find("a").each( function()
    {
        $this = $(this);
        // Modify $this
    });

// Iterate over the links a second time
$firstParagraph.find("a").each( function()
    {
        $this = $(this);
        // I want to modify $this again, but without loosing
        // the work I did in the first iteration
    });
  • 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-23T23:47:35+00:00Added an answer on May 23, 2026 at 11:47 pm

    Instead of going violently against the grain of jQuery like you’re asking, let me advise you how to do what you actually need to do: use $(this).data('somekey', someval) and $(this).data('somekey') to, instead of directly modifying $(this) as an object and so losing whatever you’re trying to do, attach data to your concept of $(this) in such a way that you’ll be able to get it back. (Docs here.)

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

Sidebar

Related Questions

I'm using jquery's .each() to iterate over a group of li's. I need a
Is there a way to iterate over every property of an object using the
I'm trying to iterate over an enum, and call a method using each of
How can I iterate over each file in a directory using a for loop?
I'm using Python to infinitely iterate over a list, repeating each element in the
I have a data fine being read in using file() and iterate over each
I am using .each function to iterate trough list of elements. I am having
If I am iterating over each file using : @echo off FOR %%f IN
I am using PHP to iterate over the following result set, the aim is
If there is a method call MyClass.returnArray() and I iterate over the array using

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.