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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:34:01+00:00 2026-05-29T09:34:01+00:00

I have a html which looks roughly like this: <tr id=row> <td id=cell_1>Cell 1</td>

  • 0

I have a html which looks roughly like this:

<tr id="row">
  <td id="cell_1">Cell 1</td>
  <td id="cell_4">Cell 4</td>
  <td id="cell_8">Cell 8</td>
  <td id="cell_9">Cell 9</td>
  <td id="cell_11">Cell 11</td>
  ...
</tr>

I have no way of changing it. For example, I have a variable cell, which points to the jQuery object representing the second td and I would like to get the element which is n cells after the cell. One way to get it would be:

var cell = $("#cell_4");

var next = cell;
for (var i = 0; i < n; i++) {
  next = next.next();
}

But I think that wouldn’t be the most proper way since it requires n amount of “moves” through the DOM. The other way I could think off involves using the index() method (not tested so it could contain some errors but I think the method is understandable):

var index = $("#row > td").index(cell);
var next = $("row td:nth-child(" + index + n + ")");

Is there a “better”, built in, way to achieve that result? For example, something which would look like this:

var next = cell.nextTimes(n);
  • 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-29T09:34:01+00:00Added an answer on May 29, 2026 at 9:34 am

    As the cells in questions have id values, if you can derive the value of the one you want from where you’re starting, you can just use $('#cell_' + derivedValue).

    But if you can’t do that, you can use nextAll and eq:

    var next = cell.nextAll().eq(n); // Or `n-1`, depends on what `n` is
    

    nextAll returns all of the element’s following (next) siblings, and eq reduces the matched set to the element at the given index.

    So for example, cell.nextAll().eq(1) starting from cell_1 in your example would return
    cell_8 (cell_4 would be cell.nextAll().eq(0)).

    Live example

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

Sidebar

Related Questions

I have a webpage with a form, which looks kinda like this: @using (Html.BeginForm(MyAction,
I have a composite control which emits HTML that looks like this <span id=myControl>
I have a HTML code which looks like this. <html><head><meta http-equiv=refresh content=0;url=http://www.abc.com/event/></head></html> I want
I have an index.html file which looks like this (the rest is omitted), <ul
I have a piece of piece of HTML which looks like this - <div
I have HTML which looks something like this: <span id=text> <span class=segment id=first>some text</span>
I have some html which looks like this: <div style={ display:inline; width: 80px}>fig</div>vitamin c<br>
I have a every common page a.html which looks like this: <html> <head> <script
I am using jQuery. I have HTML code which looks like this: <ul> <li>123</li>
All, I have a situation that looks roughly like this: My HTML page a

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.