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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:05:18+00:00 2026-05-23T03:05:18+00:00

In my index.html page, I have an empty table defined as following: <body> …

  • 0

In my index.html page, I have an empty table defined as following:

<body>
  ...
  <table width="500" border="0" cellpadding="1" cellspacing="0" class="mytable">
      <tr></tr>
  </table>
  <script src="my.js"></script>
</body>

As you saw above, there is an JavaScript file my.js is included.

my.js(which is used to update the table row):

var items = ARRAY_OF_OBJECTS_FROM_SERVER; //e.g. items=[{'John', '023567'},{'Bill', '055534'},...];

//Each object element in the "items" array contain "name" and "phone" attribute.

var mytable = $('.mytable tr:first');
for(var i=0; i<items.length; i++){
   var obj = items[i];
   mytable.after("<tr>");
   mytable.after("<td>&nbsp;</td>");
   mytable.after(" <td>"+obj.name+"</td>");         
   mytable.after("<td>"+obj.phone+"</td>");
   mytable.after("</tr>");
}

I successfully get the dynamical table working, but when I try to add mouse hover effect on each row, I just failed. What I tried is by using CSS:

.mytable tr:hover
{ 
  background-color: #632a2a;
  color: #fff;
} 
        
       

I would like the mouse hover with color highlight effect to be working on IE 7+, firefox and chrome, what is the correct way to implement the table row mouse hover effect in my case??

—-EDIT—-

Here is my index.html page:

index.html

<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>my test</title>
<link href="mystyle.css" rel="stylesheet" type="text/css" media="screen" />
</head>
 <body>
      <table width="500" border="0" cellpadding="1" cellspacing="0" class="mytable">
          <tr>
          </tr>
      </table>
  <script src="my.js"></script>
  </body>
</html>

–SOLUTION—-

@manji ‘s solution solved my problem. That’s change in JavaScript to use append instead of after inside for loop. Then, the CSS way of highlighting row is working.

  • 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-23T03:05:18+00:00Added an answer on May 23, 2026 at 3:05 am

    You are writing the <td> outside of <tr> with this:

    mytable.after("<tr>");
    mytable.after("<td>&nbsp;</td>");
    mytable.after(" <td>"+obj.name+"</td>");         
    mytable.after("<td>"+obj.phone+"</td>");
    mytable.after("</tr>");
    

    For example, first one will add a <tr> and close it, then 3 closed <td>s before the <tr> and the last one is incorrect and will have no effect.

    Try it this way and it will work:

    mytable.after("<tr>"
    +"<td>&nbsp;</td>"
    +"<td>"+obj.name+"</td>"
    +"<td>"+obj.phone+"</td>"
    +"</tr>");
    

    and it’s better to use .append() (it will add the objects in their list order):

    var mytable = $('.mytable');  // mytable selector is changed to select the table
                                  // you can remove the empty <tr>
    for(var i=0; i<items.length; i++){
       var obj = items[i];
       mytable.append("<tr>"
       +"<td>&nbsp;</td>"
       +"<td>"+obj.name+"</td>"
       +"<td>"+obj.phone+"</td>"
       +"</tr>");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jQueryMobile page anatomy at index.html: <div data-role=page> <div data-role=header>...</div> <div
I am using jQuery for a simple website and have a main page 'index.html'
If I have a single page with many forms of existing records: index.html.haml -
I am using rails beta 3 and I have a erb page named index.html.erb
I have a page named index.html . On it, I have a menu with
I have the following code in my Site.Master page of an almost empty ASP.NET
My index.html page for my project needs some Ruby code so I need to
how can i made some nice slideshow for the index.html page, with lets say
I got this jQuery pre-loading script running on a index.html page loading about 10Mb
I'm trying to set my default page to Index.html on an ASP.NET site running

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.