Hi,
How to change css dynamicaly using javascript ?
Change css dynamicaly using javascript
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rohatash KumarRank #12 · 57.7K reputationPosted Jul 15, 2011, 3:33 AM EDT
.first{ background:silver; padding:20px; color:#ffffff; } .second{ background:yellow; padding:30px; color:#000000; } Now we need to define the logic in javascript which let us interchange the two classes dynamically. function changeClass(x) { x.className=(x.className=="first")?"second":(x.className=="second")?"first":"second";