<div>
<a href="#" class="selected">link1</a>
<a href="#">link1</a>
</div>
and using following
$('.selected').html()
I get
link1
as a return value.
How can I get full html code of the selected DOM element, in this example to get
<a href="#" class="selected">link1</a>
instead?
thanks
I made a solution similar to above, but with no cloning.
You could try this jQuery plugin: http://darlesson.com/jquery/outerhtml/
I know that this works on Chrome, don't know about the rest:
That property is from javascript (not jQuery) and gives you what you're looking for.
Simply using the
outerHTML
property may not work across all browsers. You will need to serialize it yourself for browsers without support forouterHTML
. See this post for an explanation: How do I do OuterHTML in firefox?jQuery object:
become to DOM object:
UPDATE: