Map to join strings
<html> <head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ var list = $("div,p").map(function () { return this.tagName; }).get().join(", "); $("b").append(document.createTextNode(list)); }); </script> </head> <body> <span>span</span> <p>p</p> <div>div</div> <b>bold</b> </body> </html>