views:

68

answers:

2

Hi,

I'm using jquery to parse some HTML, something like:

$(html).contents().each(function(){
  var element = this.tagName;
  ...

I can access the tagName, children, parent... using the DOM or the more friendly jQuery functions.

But at one point a need the whole HTML of the current element (not what innerHTML or .html() return) and I can't figure out a one liner to get it (I always could attach the tag and the attributes manually to the innerHTML).

For example:

<a href="link">Link</a>

The innerHTML is Link but I'm looking for the whole <a href="link">Link</a>

does that oneliner exists?

Thank you.

A: 

just saw the anwser for this on the other thread :D

outerHTML

outerHTML 2

antpaw
+1  A: 

Looks like this guy has a pretty nifty solution using jQuery: outerHTML

Justin Swartsel