Checking a HTML element's class $('pre').each(function(index) {
    var c = $(this).attr("class");
    if (!c) {
        return true;
    }
    // Match only Javascript code snippets
    if (!c.match(/brush: js; class-name: 'jsbox'/)) {
        return true;
    }
    var code = $(this).text();
    $(this).after($("&lt;button&gt;Run example&lt;/button&gt;").click(function() {
        run(code);
    }));


I noticed if I didn't have if (!c) { then the loop could abrubtly halt if it found a &lt;pre&gt; element without a class.

I wonder how to write this more succinctly. I'm also wondering about my matching options, since I've noticed different ways people match / compare strings in Javascript and I wondered what was "de rigueur".
Change

var code = $(this).text();   


to

var code = $(this).val();