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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:18:28+00:00 2026-05-13T18:18:28+00:00

I’m building a table and trying to add some CSS as well as some

  • 0

I’m building a table and trying to add some CSS as well as some attributes. I can’t seem to find any workarounds for IE7.

Here is what I’m doing:

$.each(eat,function() {

//Builds tablerows
var row = document.createElement("tr");
var cellReportId = document.createElement("td");
cellReportId.appendChild(document.createTextNode(this.reportId));
var cellDescription = document.createElement("td");
cellDescription.appendChild(document.createTextNode(this.description));
var cellDrawingNumber = document.createElement("td");
cellDrawingNumber.appendChild(document.createTextNode(this.drawingNumber));

row.appendChild(cellReportId);
row.appendChild(cellDescription);
row.appendChild(cellDrawingNumber);


$(self.tblResults[0]).append(row);
})


$(self.tblResults[0]).find('tr').addClass("DynamicTableTR"); 
$(self.tblResults[0]).find('tr:not(:first)').attr("onmouseover", "this.style.background='#EDEED5'");
$(self.tblResults[0]).find('tr:not(:first)').attr("onmouseout", "this.style.background='white'");
$(self.tblResults[0]).find('tr:first').addClass("DynamicTableHeaderRow");
$(self.tblResults[0]).addClass("DynamicTable");

}

The part at the bottom doesn’t work in IE:

$(self.tblResults[0]).find('tr').addClass("DynamicTableTR"); 
$(self.tblResults[0]).find('tr:not(:first)').attr("onmouseover", "this.style.background='#EDEED5'");
$(self.tblResults[0]).find('tr:not(:first)').attr("onmouseout", "this.style.background='white'");
$(self.tblResults[0]).find('tr:first').addClass("DynamicTableHeaderRow");

If tried several different approaches in the $.each loop to format the ‘row’ element without any luck. The .attr() function will not work in IE either it seems.

On the addClass() function it does work here:

$(self.tblResults[0]).addClass("DynamicTable");

However it does not work if I try to apply it to the row in $.each loop like this:

$(row).addClass("DynamicTableTR");

I can’t seem to find any workaround for IE.

EDIT:

The issue is the css/attributes are not getting applied to the s that I’m creating.

And the defintion of self is:

var self = this;    //Capture the current self, outside of the $.each loop 

tblResults is just a already defined on my page.

  • 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-13T18:18:28+00:00Added an answer on May 13, 2026 at 6:18 pm

    Try this alternative, comment if you have any issues…without your setup I can’t test completely:

    Updated to fix the XSS possibility as bobince pointed out:

    var tbl = $(self.tblResults[0]);
    $.each(eat,function() {
      $("<tr class='DynamicTableTR' />")
        .append($("<td></td>").text(this.reportId))
        .append($("<td></td>").text(this.description))
        .append($("<td></td>").text(this.drawingNumber))
       .appendTo(tbl);
    });
    
    // This next .hover() could be replaced with a CSS rule:
    // .DynamicTableTR:hover { background: #EDEED5; }
    // Won't work in IE 6 though, maybe some other older browsers
    
    tbl.find('tr:not(:first)').hover(function() {
      $(this).css("background","#EDEED5");
     }, function() { 
      $(this).css("background", "white");
     });
    tbl.addClass("DynamicTable").find('tr:first').addClass("DynamicTableHeaderRow");
    

    If you’re using jQuery 1.4+, it recognizes snippets like this and offers a great deal of optimization behind the scenes when doing looping inserts.

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

Sidebar

Related Questions

No related questions found

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.