Applying a CSS Rule with JS

Posted on 2005-04-25
Last Modified: 2013-11-19


there is a line of JavaScript, which applies a CSS Rule "on click" or "on Rollover" to a specific item on the page, e.g. to a TD or to a font.
As I can remember (it is very long time ago), it was something like "onClick= ...", But I'm not sure.

Does somebody knows about it?
Best thanks, Gitti

Question by:Gitti
    LVL 15

    Accepted Solution

    like so?


                <span onmouseover="this.className='clsOnMouseOver';" onclick="this.className='clsOnMouseClick';"> Me </span>

    Author Comment

    Hi and thanks for the reply. Although it was the answer to my question, would you please kindly formulate this one to JavaScript?

    <span onclick="this.backgroundcolor='#993333' AND this.font-color='#ffffff'">

    I don't know why it doesn't work?
    Many thanks.
    LVL 15

    Expert Comment

    by:justinbillig but font color might just be color

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Question on web subscription for apps 3 52
    Dynamically populating 3 select boxes 14 45
    c# string 6 26
    Table append 4 11
    Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
    Shoutout to Emily Plummer ( for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
    The viewer will learn how to count occurrences of each item in an array.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now