zwwcn

Just another WordPress.com site

Monthly Archives: April 2015

Conditional operator in concatenated string


"Hazard Class changed from '" + hazardChangeTracker.getHealthSafetyClass()!=null?hazardChangeTracker.getHealthSafetyClass().getLabel():"Not Set"

The above code throws PNE because conditional operator has lower precedence level than addition operator. To make the code work, we need to add parentheses.


"Hazard Class changed from '" + (hazardChangeTracker.getHealthSafetyClass()!=null?hazardChangeTracker.getHealthSafetyClass().getLabel():"Not Set")

Advertisements

Position An awesomefont background Relative to its Container Using CSS

<div id="container">
   <div id="box"> </div>
</div>
#container {
  position: relative;
}

#box:after {
  content: "\f154"; 
  font-family: FontAwesome;
  font-size: 100px;
  position: absolute;
  top: 40px;
  left:20px;
  z-index: 1;
}

ref : http://stackoverflow.com/questions/104953/position-an-html-element-relative-to-its-container-using-css