Switch between two chunks of code
JS and CSS (and HTML)
by Lucas Krause
HTML
<div class="foo" id="foo">Foo bar baz</div>
CSS
/**
* Originally by Harry Roberts (@csswizardry)
* http://jsfiddle.net/csswizardry/Kny3Q/
*
* A neat way of quickly swapping two chunks of code in CSS. Also works in JS.
* Try adding a space BEFORE the SECOND forward slash on line 6 (or simply delete/add it).
*/
.foo{
/**/
color:red;
font-weight:bold;
/*/
color:blue;
font-style:italic;
/**/
}
JavaScript
var el = document.getElementById("foo");
/**/
el.style.border = "1px solid red";
/*/
el.style.border = "1px solid blue";
/**/
/**
* Theoretically the following HTML markup must show the same effect, but it doesn't
<!---->
<div class="foo" id="foo">Foo bar baz</div>
<!-->
<div class="foo" id="foo">hello world.</div>
<!---->
*/