You can try this:
function copyAttributes(from, to)
{
$($(from)[0].attributes).
each(function(){$(to).attr(this.nodeName, this.nodeValue);});
return $(to);
};
The return statement lets you write things like:
copyAttributes(some_element, $('')).append(...) ...
Hope this helps.