I currently have a bit of code with displays a bit of text with an animation and when the user hovers over it audio will play.
However I am adding a feature which will allow the user to change the element type. The code below at the moment changes an element from H1 to P.
It all works except that the script which detects to see if the user has hovered over the element no long seems to work. Which I think is a bit off as the element still keeps the same ID.
Is there a JS reason why the audio script will no longer work or have I missed something obvious?
Thanks!
Detects change
$("#editTextTag").change(function(){
var id = "#"+$("#editTextId").val();
var iframe = $('#clientframe');
var tag = $("#editTextTag").val();
var element = $(id, iframe.contents());
var elementcopy = $(element).clone();
var attrs = { };
$.each($(element)[0].attributes, function(idx, attr) {
attrs[attr.nodeName] = attr.nodeValue;
});
$(element).replaceWith(function () {
return $("<p/>", attrs).append($(this).contents());
});
});