ChildOfCode


Maker,Coder,Hacker,Robotic,Open Source. Knowledge Base


JQuery addClass render

A solution for the Jquery add class can't render issue.

CSS

/* Render at First */
#targetDiv {
  padding: 0px 25px 0px 5px;
  margin: 0px;
  position: absolute;
  right: 0;
  top: 43px;
}

/* Rerender the Div */
.TargetDiv_addClass {
  top: 0px !important;
}

JavaScript

TargetDiv.addClass("TargetDiv_addClass");  

The !important exception

When an !important rule is used on a style declaration, this declaration overrides any other declaration made in the CSS, wherever it is in the declaration list. Although, !important has nothing to do with specificity. Using !important is bad practice because it makes debugging hard since you break the natural cascading in your stylesheets.

refer:
https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

http://stackoverflow.com/questions/16131523/jquery-add-class-but-chrome-doesn-t-render