jquery 获取outhtml

jquery 如何获取outHTML 呢?

方式一:

var outer_html = $('selector')[0].outerHTML ;
console.log(outer_html);

方式二:

outer_html = $('selector').clone().wrap('<p>').parent().html();

 参考:http://aghoshb.com/articles/jquery-getting-a-selected-elements-outer-html.html

http://stackoverflow.com/questions/5744207/jquery-outer-html

相关推荐