Control.addStateClass

Syntax

addStateClass (value);

Parameters

value. Name of the CSS class.

Description

The addClass method adds CSS class to the component and removes the previous CSS class.

Example

To execute the example the HTML page must contain links to the PP.css, PP.js and jquery.js files. Add the TextArea component to the page, sets offsets, new border type and fill color for this component:

     textArea = new PP.Ui.TextArea({
        ParentNode: document.body,
        Content: "Text"
     })
      textArea.addStateClass("newStyle")
      if (textArea.hasClass("newStyle")) {
        // Set styles for the class
        $("div.newStyle").css("margin", "20px");
        $("div.newStyle").css("border", "1px dashed");
        $("div.newStyle").css("background-color", "#FFF8DC")
     } else {
        console.log("The newStyle CSS class is not found.");
     };
     console.log("Font color: " + textArea.getCssStyle(textArea.getDomNode(), "background-color"));
     //Clear the component styles cash
     textArea.clearStylesCache(); 

After executing the example the page will contain the TextArea component that looks as follows:

Browser console will show background color in RGB format:

Background color: rgb(255, 248, 220)

See also:

Control