Here’s a nifty little trick that allows you to write “contextual” JavaScript. It’s incredibly obtrusive and probably shouldn’t be used at all but it’s still a pretty cool idea: <div id="some-div"> <script type=":contextual"> alert(this.id); // "some-div" is alerted </script> </div> Instead of the this keyword referencing the global object (window) we can make it reference the parentNode of the scr