开发者

Getting the outer div in JQuery [duplicate]

开发者 https://www.devze.com 2023-03-25 07:23 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Get selected element's outer HTML
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Get selected element's outer HTML

I'm getting a class like this:

   <div class="clas开发者_运维知识库sName">
      content in here
   </div>

And then I'm getting it in JQuery like this:

$('.className').html()

Which only outputs:

content in here

When I want it to get everything, including the parent div.

Thanks for any help


$('.className').clone().wrap('<div></div>').parent().html();

http://jsfiddle.net/ipr101/WX69N/

0

精彩评论

暂无评论...
验证码 换一张
取 消