I'm trying to create a jquery setup where all instances of <i>
are changed to <em>
. It's easy enough to do with:
$("i").each(function(){
$(this).replaceWith($('<em>' + this.innerHTML + '</em>'));
});
But what I am having trouble figuring out is how to change all the <i>
tags but retain each ones individual attributes. So if I have <i style="background-color: #333;" alt="Example" title="Example">Example Text</i>
I would like it to change to <em style="background-color: #333;" alt="Example" title="Example">Example Text</em>
Thanks for any help!