1 Reply Latest reply on Oct 14, 2010 11:17 PM by BhaskerChari

    Set CSS Programatically?

    estabahn

      I want to set the css class for a component at runtime. If I have 2 buttons with ids of button1 and button2 how can I set their css class programatically at runtime? 

       

      Thanks!

        • 1. Re: Set CSS Programatically?
          BhaskerChari Level 4

          Hi estabahn,

           

          You can make use of setStyle() method for assigning the css class styles at runtime.

           

          button1.setStyle("styleName", "myButton1");

          button2.setStyle("styleName", "myButton2");

           

          where myButton1 and myButton2 are css styles.

           

          .myButton1

          {

               color:#ff0000;

               font-size:14;

          }

           

          .myButton1

          {

               color:#ff0000;

               font-size:14;

          }

           

          Thanks,

          Bhasker