1
How do I get the outerHTML of a jquery object? The following is not working.
$("selector").outerHTML;
1
How do I get the outerHTML of a jquery object? The following is not working.
$("selector").outerHTML;
4
A jQuery object has in it a reference to the native element you want and you can extract it with $('selector')[0]
, from there you can use native JS.
var outer = $('selector')[0].outerHTML;
Another option is to create a temporary element where the first one is inserted and the .html()
. You may need this solution if you have several elements.
var outer = $('<div>').append($('selector').clone()).html();
or without having to clone:
var outer = $('selector').wrapAll('<div>').parent().html();
1
Use
$("selector")[0].outerHTML;
Browser other questions tagged javascript jquery html
You are not signed in. Login or sign up in order to post.
I believe this topic will help you: http://stackoverflow.com/questions/5744207/jquery-outer-html
– Rafael Withoeft