tags:

views:

55

answers:

2

if i call

jquery("a").html()

i get what is INSIDE of the "a" tag

if i want the entire html, what do i call?

<a>xxxx</a>
+5  A: 
jQuery.fn.outerHTML = function() {
    return jQuery('<div />').append(this.eq(0).clone()).html();
}
jQuery('a').outerHTML(); // <a>xxxx</a>
eyelidlessness
A: 

What you want is outerHTML and there is no direct way to get that in jQuery. You can write your own function

jQuery.fn.outerHTML = function() {
    return $('<div>').append( this.eq(0).clone() ).html();
};

$("yourselector").outerHTML();

In javascript you can use outerHTML, but isn't compatible with every browser. Take a loot at outerHTML

rahul