Home News Contact Us Forum About Us Demos Products F.A.Q.
Shopping Cart
You currently have 0 items in your cart.


Recent Events
  • 31/12/2023 New Year SALE

    We are glad to announce New Year SALE. 25% discount for all our extensions. Use NY24 coupon code. Hurry up the discount is valid till 7 January.

  • 21/11/2023 BLACK FRIDAY 23 is coming

    BIG SALE, 35% discount for all our extensions. Use BF23 coupon code. Hurry up the discount is valid till 27 November.


2Checkout.com, Inc. is an authorized retailer of goods and services provided by ARI Soft. 2CheckOut




Follow us on twitter



Welcome, Guest
Please Login or Register.    Lost Password?

Add CSS class to a table cell
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Add CSS class to a table cell
#64289
Add CSS class to a table cell 5 Years, 3 Months ago Karma: 0
Hey there!

Is it possible to add a CSS class to a table cell based on it's content?

I'm dealing with a sports website and we need to display a list of clubs in a table. The source comes from a CSV on a remote server of the main sports association. I can easily display the table with it's contents but we would like to add some CSS styling specific to each one of the clubs. The table includes club names in each cell and we would like to add class based on that content of the cell.

Can it be done?
JxM
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#64290
Re:Add CSS class to a table cell 5 Years, 3 Months ago Karma: 746
Hello,

Sorry, but the extension doesn't support this ability.

Regards,
ARI Soft
The administrator has disabled public write access.
 
#64292
Re:Add CSS class to a table cell 5 Years, 3 Months ago Karma: 0
Thanks for the answer!

I guess in this case I might find a solution in jQuery? I’ve been doing sime research and maybe :contains function might help?
JxM
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#64295
Re:Add CSS class to a table cell 5 Years, 3 Months ago Karma: 746
It seems the following javascript code can be used if want to add "red" CSS class for cells which contains 2018:

Code:


jQuery('.dataTable tbody td:contains("2018")').addClass('red')



Regards,
ARI Soft
The administrator has disabled public write access.
 
#64301
Re:Add CSS class to a table cell 5 Years, 2 Months ago Karma: 0
Hey!

I tried it, but it didn't work straight out of the box. Had to change it a bit, like this:

Code:

jQuery(function ($) {
  $('td:contains("Team 1")').addClass('team1');
});



Now it works great! Thanks! And Happy New Year!
JxM
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1