简体   繁体   English

如何(wrapInner或wrapAll)不包括第一个div类

[英]How To (wrapInner or wrapAll) Excluding first div class

在此处输入图片说明

I want to wrap all the items below "name portlet-title" But, Should not include other items in "div class name portlet-title" below. 我想将所有项目包装在“名称portlet-title”下,但是,不应在下面的“ div类名称portlet-title”中包括其他项目。 where i tried following ways: 我尝试以下方式:

1) $("div.item").wrapAll('<div class="portlet-body"></div>'); 1) $("div.item").wrapAll('<div class="portlet-body"></div>');

it is effecting all item in page. 它会影响页面中的所有项目。

2) $("div.list").wrapInner('<div class="portlet-body"></div>'); 2) $("div.list").wrapInner('<div class="portlet-body"></div>');

it is including "div class name portlet-title" 它包括“ div类名portlet-title”

i am not so good at jquery please help me out. 我不太擅长jquery,请帮帮我。

You need to use a loop so that you can group the items separately. 您需要使用循环,以便可以分别对项目进行分组。

$('.list.portlet').each(function(){
    $(this).find('div.item').wrapAll('<div class="portlet-body"></div>')
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM