Posted by Shane Becker on
<p>This:</p>
<code><pre>
changeSize: function(size) {
$$('div.what_it_looks_like').invoke("hide");
$(size).show();
}
</pre></code>
<p>is better than this.</p>
<code><pre>
changeSize: function(size) {
switch(size) {
case 'medium_rectangle' :
$('medium_rectangle').show();
$('skyscraper').hide();
$('leaderboard').hide();
break;
case 'skyscraper' :
$('medium_rectangle').hide();
$('skyscraper').show();
$('leaderboard').hide();
break;
case 'leaderboard' :
$('medium_rectangle').hide();
$('skyscraper').hide();
$('leaderboard').show();
break;
}
}
</pre></code>
<p>And I'm still a Javascript n00b.</p>