javascript if function – created on other way  [ 681 views ]

Goal: to go out of box…

The if construction is simple

if(someThing == 'value'){
  $(this).stop().animate({'opacity':0}, 250);
  this.obj.isHidden = true;
}

Meanwhile I use the following for in many cases:

someThing == 'value' && (
  $(this).stop().animate({'opacity':0}, 250),
  this.obj.isHidden = true
);

But! Never use return from the comma chain!

someThing == 'value' && (
$(this).stop().animate({'opacity':0}, 250),
this.obj.isHidden = true,
return true; /* <-- NEVER! */ ); return false; [/js] just good to know...

#sidebar a { color:#fff; } #sidebar ul ul li { color: #DEF585; } #sidebar h2 { color: #fff; } #sidebar ul p, #sidebar ul select { color: #BEDDBE; } #backfly { background: url(images/golfBallWallPaper.jpg) left bottom fixed repeat-x #65a51d; }