开发者

Getting the outer div in JQuery [duplicate]

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜