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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:41:47+00:00 2026-05-26T19:41:47+00:00

I tried some different ways do find rows in a table where a columns

  • 0

I tried some different ways do find rows in a table where a columns contain a particular link.

My goal: replace an icon when a link to xyz is in this same row as the image.

This is my snippet so far:

var rows = document.getElementsByTagName("tr");
for(var i = rows.length - 1; i >= 0; i--) {     
        var links = rows[i].getElementsByTagName("a");
        for(var k = links.length - k; k >= 0; k--) {
            if (links[k].href =="http://www.XXXX.net/forum/index.php?showforum=121"){
                var images = rows[i].getElementsByTagName("img");
                    for (var j=0;j<images.length;j++) {
                    images[j].src = "http://www.XXXX.net/forum/folder_post_icons/icon7.gif";
                    }
            }
        }
}

I’m pretty sure this is not really the best concept. But as you might see I try to search links in all rows and once the link to forum “121” is found, I try to replace all images in this particular row.

What I get is every image at the site getting replaced.

  • 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-26T19:41:48+00:00Added an answer on May 26, 2026 at 7:41 pm

    Since it’s simple enough, here’s a complete script that does that.
    It uses jQuery and here’s a handy jQuery reference. See, especially, the Selectors section (which are almost the same as CSS Selectors).

    Re: "What I get is every image at the site getting replaced." …

    This maybe because the search criteria is too broad. If it’s a poorly designed (uses table layouts) page, every image may be in a table row with a target link!

    When posting Greasemonkey questions, link to the target page, or at the very minimum, post enough of the page’s HTML that we can adjust the GM script to match.


    Anyway, this will work, possibly pending more information about the target page:

    // ==UserScript==
    // @name     _Replace image on custom-targeted row
    // @include  http://www.XXXX.net/forum/*
    // @require  http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
    // ==/UserScript==
    
    //--- This may need tuning based on information not provided!
    var targetLinks = $("tr a[href*='showforum=121']");
    
    //--- Loop through the links and rewrite images that are in the same row.
    targetLinks.each ( function () {
        //--- This next assumes that the link is a direct child of tr > td.
        var thisRow = $(this).parent ().parent ();
    
        //--- This may need tuning based on information not provided!
        var images  = thisRow.find ("td img");
    
        //--- Replace all target images in the current row.
        images.each ( function () {
            $(this).attr (  
                'src', 
                'http://www.XXXX.net/forum/folder_post_icons/icon7.gif'
            );
        } );
    } );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to find some decent documentation on traversing in jQuery, but have
Hello I have tried this many different ways and have followed the tutorial at
I have read many articles so far and tried so many different ways to
So I tried executing a script two different ways: 1) foreach($result_array as $arg){ exec(/usr/bin/php
I try to draw some lines with different colors. This code tries to draw
I tried some add to favorties JavaScript scripts.. With IE8, I get an access
Just tried some small graphics application of mine on Windows 7, and I'm getting
I've looked for some other articles on this problem and even tried some of
I'm just curious to know about this.When i heard about Spring.net and tried some
I am very interested in streaming data for web-applications. I have tried out some

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.