i wrote a really simple plugin for this, as i frequently have the same use case:
jQuery.fn.outerHTML = function() { return jQuery("<div/>").append( jQuery(this[0]).clone() ).html(); } so that i could call it on any element, such as: $("#fooID").outerHTML(); On Aug 19, 9:55 am, John <jian.fang.subscr...@gmail.com> wrote: > That works. Really appreciate your help. -John > > On Aug 18, 7:48 pm, mkmanning <michaell...@gmail.com> wrote: > > > outerHTML is an IE addition to the DOM and not supported by Firefox. > > If you want to get it with jQuery just append the element to a div and > > get itshtml(): > > > $('<div>').append( $("table:first").clone() ).html() > > > On Aug 18, 4:37 pm, Jules <jwira...@gmail.com> wrote: > > > > Use DHTML property. > > > > $("table:first")[0].outerHTML > > > > On Aug 19, 12:36 am, John <jian.fang.subscr...@gmail.com> wrote: > > > > > Thanks, Anurag. Let me rephrase my question. For example, I can use > > > > the following jQuery > > > > to get thehtmlsourceof a table element > > > > > $("table:first").html() > > > > > The returnedhtmlsourcedoes not include the table itself, I like to > > > > see thehtmlsourcestarting > > > > from the table, for example, > > > > > <table class="aaa"> > > > > ...... > > > > </table> > > > > > Is there any jQuery function for this? If not, how do I implement > > > > this? > > > > > Thanks in advance, > > > > > John > > > > On Aug 18, 2:06 am, anurag pal <mail.anurag....@gmail.com> wrote: > > > > > > Hi John, > > > > > > After setting thehtmlby usinghtmlmethod you have to bind the DOM > > > > > elements using bind method. > > > > > > Example: > > > > > <script type="text/javascript"> > > > > > $(".pge").bind("click", function(e){ > > > > > var options = {}; > > > > > $.ajax({ > > > > > url: "data_retrieval.php", > > > > > cache: false, > > > > > type: "GET", > > > > > data: ({id : this.getAttribute('id')}), > > > > > > success: function(html){ > > > > > $("#slacker_detail_view").html(html); > > > > > $('#slacker_detail_view').show('blind', > > > > > options, > > > > > 1500); > > > > > } > > > > > }); > > > > > }); > > > > > </script> > > > > > > Regards, > > > > > Anurag Pal > > > > > > On Tue, Aug 18, 2009 at 7:40 AM, John <jian.fang.subscr...@gmail.com> > > > > > wrote: > > > > > > > Hi, > > > > > > > How do I get back the DOM element asHTMLsourceusing jQuery? Thehtml > > > > > > () method only returns the innerHTML and it does not include the UI > > > > > > element itself. But I am more interested in converting the UI > > > > > > element > > > > > > itself toHTML. > > > > > > > Thanks in advance, > > > > > > > Jian