jQuery.fn.replaceWith = function(replacement) {
  return this.each(function(){
    element = $(this);
    $(this)
      .after(replacement).next()
      .html(element.html());

   /*if (element.attr('class')) {
    element.next().attr('class', element.attr('class'));
   }

   if (element.attr('id')) {
    element.next().attr('id',element.attr('id'));
   }*/

   element.remove();
  });
};