Bootstrap collapse within a foreach loop

前端 未结 1 1987
轮回少年
轮回少年 2021-01-18 17:40

I am having trouble getting the collapsible panels to work within my foreach loop. When an item is clicked, all of the items expand/retract, which isn\'t what I want. I wa

1条回答
  •  死守一世寂寞
    2021-01-18 18:11

    Basically you are creating panel with loop and assigning the same id to all the panel-group and that's what causing the problem here! So you can try working as below and please note ids should be unique in DOM

    @{int i=0;}
    foreach (var item in groupItem)
    {
           
    @Html.DisplayFor(modelItem => item.IdNumber)
    i++; }

    0 讨论(0)
提交回复
热议问题