Select different elements with wrapAll — jQuery

前端 未结 2 1241
栀梦
栀梦 2021-01-16 13:45

I am trying to wrap both a h1 tag and multiple p tags into one div using jQuery wrapAll.

Here is my HTML:

<         


        
2条回答
  •  花落未央
    2021-01-16 14:24

    Have you tried to just add p inside the selector:

    $('.postwrap').each(function(){
        $(this).find('h1, p').wrapAll('
    '); $(this).find('.img').wrapAll('
    '); });

提交回复
热议问题