function addExpandelator(){ var addExpander = function(t,i){ $(t).find('a[href]').first().parent().prepend('E)'+i+") "); return; }; var trs = $('#replies_table tr[class]'); for( var ix = 0; ix < trs.length; ix++){ if( trs[ix].className.match( new RegExp( '^reply$' ) ) ){ if( ( ix == ( trs.length -1 ) ) || ( trs[ix+1] && trs[ix+1].className.match( new RegExp( '^reply$' ) ) ) ){ addExpander( trs[ix], ix ); } } } return; }