引导手风琴为活动面板找到id值

时间:2018-07-10 13:08:34

标签: twitter-bootstrap

我使用

$('#accordion .collapse').on('show.bs.collapse', function () {

    var id = $('#accordion .in').parent().attr("id");
    alert(id);
}

当我试图从引导式手风琴中为活动面板的部分视图中的“ id”提取数据,但是却得到“ undefined”-我需要获取值id="@Html.Raw(item.Value)“:

<div class="panel-group" id="accordion">

    @foreach (var item in Helper.GetQuestions(Model.Username))
    { <div class="panel panel-default">

        <div class="panel-heading accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion" data-target="#@Html.Raw(item.Value)">

            <h4 class="panel-title" onclick="getAll(@Html.Raw(item.Value))"><b>Q @Html.Raw(item.Value) : </b>@Html.Raw(item.Text)</h4>

        </div>

        <div id="@Html.Raw(item.Value)" class="panel-collapse collapse">

            <div class="panel-body">

                <p>

                    <div class="row">

                        <div class="col-sm-12">

                            @{ Html.RenderPartial("_AllQuestions", new _AllQuestionsVM() { Username = Model.Username }); }

                        </div>

                    </div>

                </p>

            </div>

        </div>

    </div> }

</div>

任何帮助将不胜感激。

0 个答案:

没有答案