How To Get Outerhtml With Jquery In Order To Have It Cross-browser
Solution 1:
You don't need convert it to text first (which is what disconnects it from the handlers, only DOM nodes and other specific JavaScript objects can have events). Just insert the newly created/modified node directly, e.g.
$('#old-button').after(buttonField).remove();`
after
returns the previous jQuery collection so the remove
gets rid of the existing element, not the new one.
Solution 2:
Try this one:
var html_text = `<INPUTid=butonFshi1value=Fshisrc="images/square-icon.png"type=imagejQuery15205073038169030395="44">`
buttonField[0].html(html_text);
:)
Solution 3:
Check out the jQuery plugin from https://github.com/darlesson/jquery-outerhtml. With this jQuery plugin you can get the outerHTML from the first matched element, replace a set of elements and manipulate the result in a callback function.
Consider the following HTML:
<span>My example</span>
Consider the following call:
var span = $("span").outerHTML();
The variable span is equal <span>My example</span>.
In the link above you can find more example in how to use .outerHTML() plug-in.
Solution 4:
This should work fine:
var outer = buttonField.parent().html();
Post a Comment for "How To Get Outerhtml With Jquery In Order To Have It Cross-browser"