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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:39:49+00:00 2026-05-25T23:39:49+00:00

On my page I have a search form which generates a table for the

  • 0

On my page I have a search form which generates a table for the results. In that table, each cells content is surrounded by a span tag with an ID based on the cells name and rows ID in the database. In addition the span gets a fixed class. Heres a printed example:

<td><span id="firstname_203" class="text">John</span></td>

What I am trying to do, is that when I hover the cell that contains the firstname, I want the firstname to appear on a different part of the page. I have tried the code below, but it only returns firstname=null:

( function($) {
    $(document).ready(function() 
    {
    $(".text").hover(function() 
    {
    var ID=$(this).attr('id');
    var firstname=$("#firstname_"+ID).html();
    $($(".firstname")).html("firstname="+firstname);
    });
});
} ) ( jQuery );

It’s the ID part that doesn’t work because if i hardcode the ID (e.g. “#firstname_203”) it works just fine.

When I think about it, the only thing I need to know is how to get the php generated integer following the ID.

Update:

When adding more variables (this).text didn’t work as it returned the whole rows values. Instead I had to use this:

$("#table td:nth-child(1)").hover(function(event){

and return the cells as:

var firstname= $td.eq(0).text();

and so on.

  • 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-25T23:39:50+00:00Added an answer on May 25, 2026 at 11:39 pm

    You can just skip the whole Id kerfuffle and go straight to the .html().

    (function($) {
        $(document).ready(function() {
            $(".text").hover(function() {
                var firstname = $(this).html();
                $(".firstname").html("firstname=" + firstname);
            });
        });
    })(jQuery);
    

    Also, you could probably just get away with using .text()

    EDIT:

    Given this html

    <div class="userDetails">
        <span class="fname">Barry</span>
        <span class="lname">Smith</span>
    </div>
    
    <div class="firstname">Firstname</div>
    <div class="lastname">Lastname</div>
    

    You could do:

    (function($) {
        $(document).ready(function() {
            $(".userDetails").hover(function() {
                var firstName = $('.fname', this).text();
                var lastName = $('.lname', this).text();
                $(".firstname").html("firstname=" + firstName);
                $(".lastname").html("lastname=" + lastName);
            });
        });
    })(jQuery);
    

    I’ve created a jsFiddle for you – http://jsfiddle.net/HZRSW/

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

Sidebar

Related Questions

If I have a page that generates search results based on some ajax components
I have a search page that if there is results in the list it
I have two forms on one page: a results form and a search form.
i have a search form page, which takes me to reslutant page and show
I have a search form that, once submitted loads the results of the search
I have this page which loads quotes. It has a search form wherein if
what I have: a google search form (displayed on all pages) a wordpress page
I have a search page on my MVC site that contains a list of
I have a search functionality on my site that is accessible from every page.
I have a customer index page that displays customer lists. I have a search

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.