Avatar of cofactor
cofactor

asked on 

How to change value of css attribute

How to change the value of  css attribute of a tr ?

I tried this way but this does not work

document.getElementById(trId).class.value = some_value;  // trId is passed

why this does not work ?
JSPCSSJavaScript

Avatar of undefined
Last Comment
zappafan2k2
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of cofactor
cofactor

ASKER

>>>document.getElementById(trId).className = some_value;

This worked fine.
Thanks
Avatar of zappafan2k2
zappafan2k2

One thing to remember is that this command will replace any current class(es) assigned to it.  This is just one of the many reasons jQuery is so enticing, because there is built-in functionality for adding and removing classes (without worrying about the possibility of a current class).
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo