2012-07-28 34 views
3

我使用jQuery获得一排容器标签如何获得内容,并与jQuery

<tr class="phoneNumber"> 
    ABC... 
</tr> 

,当我做$( “phoneNumber的”)。HTML(),它返回ABC...
有没有办法让

<tr class="phoneNumber"> 
    ABC... 
</tr> 

在此先感谢

+0

[如何获得innerHtml,包括标签,使用jQuery?](http://stackoverflow.com/questions/2319213/how-to-get-the-innerhtml-including-the-tag-使用-jquery) – Shyju 2012-07-28 05:16:07

+0

http://stackoverflow.com/questions/2419749/get-selected-elements-outer-html有你的答案 – 2012-07-28 05:18:03

回答

2
(function($) { 
    $.fn.outerHTML = function() { 
    return $(this).clone().wrap('<div></div>').parent().html(); 
    } 
})(jQuery); 

$('.phoneNumber').outerHTML();