<a href="#" onclick="el = document.getElementById('foo'); el.style.display = (el.style.display == 'none') ? 'block' : 'none';" >click</a>
<div id="foo">
stuff here
</div>
<div id="foo" style="display: none;">
stuff here
</div>
<a href="#" onclick="el = document.getElementById('foo'); el.style.display = (el.style.display == 'none') ? 'block' : 'none'; return false;">click</a>prev() function.<div id="foo"> Like so</div id="foo">I find it really useful for managing my own disorganization, however the w3c does not agree with me, and for some stupid reason using this trick keeps pages from validating. Strictly speaking, they want you to only name the id or class for the opening tag. If somebody can explain why this is mandatory, I will be chastened, but until then I think it's dumb.
-moz-border-radiusWhich gives you nice, rounded boxes without using images or hacks. Doesn't work in IE, but it doesn't break the page, either, it just shows them as regular square boxes.
h1 {color:blue;}#menu {background-color:blue; color:white;}#menu h1 {color:yellow;}This says that by default, all H1s in your document have blue text. But what if you want to have a blue menu with white text? Your H1 isn't going to be visible, because it is the same color as the background. Using the third statement there, you are declaring that even though H1s are usually blue, any H1 used inside a #menu will be yellow instead.</div><!-- /foo -->
<span id="hidetext">HERE IS SOME TEXT.</span><br />
<select onchange="document.getElementById('hidetext').style.display=this.options[this.selectedIndex].value">
<option value="block">Show the text.</option>
<option value="none">Hide the text.</option>
</select>
function getElementsByClassName(oElm, strTagName, strClassName) {
var arrElements = (strTagName == "*" && document.all) ? document.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
var oElement;
for(var i=0; i<arrElements.length; i++) {
oElement = arrElements[i];
if(oRegExp.test(oElement.className)) {
arrReturnElements.push(oElement);
}
}
return (arrReturnElements)
}
<link rel="stylesheet" href="foo.css">inside a server-side include. The bad thing about style sheets being cached is that you can't un-cache them if something turns out to cause huge problems in some browser.
<link rel="stylesheet" href="foo2.css">and be certain that everyone's CSS has reloaded. You get the best of client-side and the best of server-side.
Favourite sites?
Roger Johansson 's 456 Berea St;
Derek Featherstone's Box of Chocolates;
Simple Bits (oddly styleless at the moment);
Andy Clarke's All That Malarkey;
Andy Budd.
It's a good idea to keep an eye on the del.icio.us/popular page will lead you to many a good article/tutorial/website.
posted by ceri richard at 11:01 AM on March 16, 2006