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 182859

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:00:50+00:00 2026-05-11T15:00:50+00:00

I have a table that looks something like this. <table> <thead> <tr> <th>Foo</th> <th>Bar</th>

  • 0

I have a table that looks something like this.

<table>   <thead>     <tr>       <th>Foo</th>       <th>Bar</th>     </tr>   </thead>   <tbody>     <tr class='data'>       <td>Info here</th>       <td><a href'/url_here' class='edit'>Edit</a></td>     </tr>     <tr class='data'>       <td>More here</th>       <td><a href'/url_here' class='edit'>Edit</a></td>     </tr>   </tbody> </table> 

I want to show the Edit link when you mouse over any of the rows inside of the . I have tried a few methods of doing this, but keep hitting the same problem. Assuming I’m just thinking about this the wrong way.

This is what I currently Have.

$('a[class*=edit]').hide();   $('tr[class*=data]').bind('mouseover', function(e) {   $(e.target).closest('a[class*=edit]').addClass('selected');   $('a[class*=selected]:first').show(); }).mouseout(function() {   $('a[class*=selected]').hide();   $('a[class*=edit]').removeClass('selected'); }) 

Problem with the existing code is it’s not adding the selected class unless you hover directly over the edit link. Like I mentioned above I need it to add the selected class when you mouse over anywhere in the that row. I also only want it to display the edit link for that specific row.

Any help would be really appreciated been pulling my hair out for a couple hours and I know it is probably something stupid. Thanks!

  • 0 0 Answers
  • 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. 2026-05-11T15:00:51+00:00Added an answer on May 11, 2026 at 3:00 pm

    A few things:

    • The string that you pass to the magical $() jQuery function can be the equivalent of what you may put in a CSS stylesheet if you wanted to style a particular element. The way you are using the selectors right now is wildly inefficient in addition to not being very clear. For example, using the =* selector is trying to find all links with the string edit anywhere in the class attribute. So links with a class of abceditabc would match. This makes jQuery do much more work than necessary trying to find these non-existent links. The accepted usage is instead to use a selector string such as a.edit which jQuery can quickly determine what it is and how to get it.
    • Whenever you do an event binding like you are doing, this refers to the element that the event is currently being acted on inside the function. Unless you are doing event delegation, you’re not really going to use e.target.
    • The reason your code is only working when the hover is directly over the link is because whenever you hover over a different cell e.target would be a sibling td. closest does not have the ability to then traverse up that td, to the tr, to the next td down to the link. And even if it did, you probably want to avoid this as it’s not necessary. This ties to the second point, as it is much easier to simply look for the link coming down from the table row.

    So, keeping these things in mind, you can rewrite what you have to this:

    $(function() {     $('a.edit').hide(); // hide all links with a class of edit     // act upon all table rows with a class of data     $('tr.data').hover(function() {         // at this point, 'this' is the table row that is being hovered         // we can use the find function to locate the link with a class of edit         // then add a class to it and show it.         $(this).find('a.edit').addClass('selected').show();     }, function() {         // the second argument of the hover function is what should happen         // when the mouse hovers out of the table row. In this case, we want         // to find the link again, remove the class, and hide it.         $(this).find('a.edit').removeClass('selected').hide();     }); }); 

    You can see the code this code acting on the HTML you posted here. Works for me on FF, IE.

    A couple further suggestions:

    • Always have the jQuery documentation open. It is very good at explaining how things work.
    • Get used to using Firefox/Firebug when debugging your jQuery. Using console.log(this); inside your selectors when you want to see exactly what is being selected is a functionality that cannot be understated.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer TO my knowledge, there is not an easy way to… May 11, 2026 at 4:25 pm
  • Editorial Team
    Editorial Team added an answer You can definitely use a DLL. I used the same… May 11, 2026 at 4:25 pm
  • Editorial Team
    Editorial Team added an answer Take a look at http://codeplex.com/TaskService May 11, 2026 at 4:25 pm

Related Questions

Lets say I have a table containing several hundred million rows that looks something
I have a aspx page that looks something like this: <tr id=Row1> <td>Some label</td>
I have a aspx page that looks something like this: <table runat=server id=tblTEst> <tr
I have an in-memory table that might looks something like this: Favorite# Name Profession

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.