jQuery(document).ready(function(){ jQuery("count").each( function(){ $self = jQuery(this) var comment_num = $self.attr("id"); $self.replaceWith( "" + comment_num + "" ); }); });