I'm just testing out my javascript to toggle code sections in my blog. It's a useful feature to help keep your blog appears short while still provides enough details.
Show codeThe javascript I use:
function toggle(id) {
var e = document.getElementById(id);
e.style.display = e.style.display == "none" ? "block" : "none";
}
Then create an anchor to control the toggling:
<a href="javascript:void(0)" onclick="toggle('thecode')">Show code</a>
<div id="thecode" style="display:none"> my code goes here <div>
Hope this works :)