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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:55:21+00:00 2026-06-01T00:55:21+00:00

I am creating html dynamically using perl, mysql and JS/Jquery … the basic structure

  • 0

I am creating html dynamically using perl, mysql and JS/Jquery … the basic structure of the pages is created in a perl loop to print multiple repeating lines – the essence of which is:

print "<div id='eventList'>";
print-loop {
   <div class="eventRow">
      <div class="eventHiddenType">$typeid</div>
      <div class="colE1">$datestring</div>
      <div class="colE2">$venue</div>
      <div class="colE3">$title</div>
   </div>
}
print '</div>'

The $vars are correctly extracted from the DB at runtime.

$typeid which is stored in a hidden div is for later use in the JS (see below)

The CSS is:

#eventList { width:900px; height: 454px; overflow-x:hidden; overflow-y:scroll; }
.eventRow { overflow: auto; height: 58px; }
.eventHiddenType { float:left; display:none; padding: 0px; margin: 0px; }  
.colE1 { float: left; width: 165px; color: #000; }
.colE2 { float: left; width: 290px; color: #000; }
.colE3 { float: left; width: 395px; color: #000; }

.EvDiv0 { background-color: #000000 !important; }   // Type 1
.EvDiv1 { background-color: #C6FFED !important; }   // Type 2
.EvDiv2 { background-color: #B3CCFF !important; }   // Type 3
.EvDiv3 { background-color: #DAB0FF !important; }   // Type 4

The html is written by calling perl from Jquery via $.ajax (with async: false)

I then stripe the rows with :

$(".eventRow:even").css('background-color', '#f3f3f3'); 

… which works as it should.

The problem lies in me attempting to then change the background color of the first cell in each row with .addClass() according to the value stored in hidden div with class of .eventHiddenType with:

$('.eventRow').each( function() {
   var hid = 'EvDiv' + $(this).children('.eventHiddenType').text();  
   $(this).children('.colE1').addClass(hid);
});

The source is correctly changed to

<div class="colE1 EvDiv3">blah blah blah</div>

… for every row … ie with the correct “EvDivX” class added (according to X = hidden type)

But the background isn’t rendered as such in the browser – it’s just as it was with the stripe all the way across.

I even tried adding a ‘!important’ to the class thinking it would force it through but it didn’t …

I know there are several other ways to achieve the effect I want but I can’t see why this one doesn’t work.

See it in action: http://jsfiddle.net/Upland/2KBPU/1/

Any ideas?

  • 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-06-01T00:55:22+00:00Added an answer on June 1, 2026 at 12:55 am

    The problem is that you have invalid comment tags in your CSS, and that’s causing the CSS interpretation problem. // is not valid but /* ... */ is. And as I noted in my comment above, you’re also generating a class, EvDiv4, which doesn’t seem to be defined.

    Updated jsFiddle example.

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

Sidebar

Related Questions

i am creating the textboxes dynamically using jquery on a button click. <table width=100%
I'm creating a dropdown box dynamically in jQuery by appending html as follows: .append(<br><SELECT
I am dynamically creating an HTML table by using a repeater. I have four
I am creating HTML pages with a base string and annotations on top of
I have a website that right now, runs by creating static html pages from
I am creating a registration page in HTML, PHP, and MySQL. I want to
I'm dynamically creating option elements for a drop down menu using Javascript and would
I'm creating some HTML elements dynamically via JavaScript. Something line this: var author =
I am creating a large table dynamically using Javascript. I have realised the time
I am creating several image dynamically using the following code: function refresh_gallery(galleryidentifier, albumid) {

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.