Woah -- don't do all this stuff. Never assemble html using strings, it leads to XSS vulns. That's why we were using jquery in the first place.    I'm open to other safe ways to do it but direct string manipulation is best avoided.    (Admittedly the previous code wasn't super-great either, in terms of the '+' concatenation.)