0

我有一个动态创建的可折叠集。我需要找出在可折叠集中展开的元素。

如果是列表,我们可以像这样获取点击的列表元素,

$('ul').children('li').on('click', function () {
                 name = $.trim($(this).text());
});

我怎样才能为可折叠套装做到这一点?

谢谢:)

4

1 回答 1

1

您可以在构成 a 的 s上使用expandcollapse事件collapsiblecollapsible-set

$(document).on("expand", "div[data-role=collapsible-set] div[data-role=collapsible]", function(){
    var title = $(this).find(".ui-btn-text")
                       .contents()
                       .filter(function(){
                           return this.nodeType == 3;
                       }).text();
    alert("Expanded: " + title);
});

$(document).on("collapse", "div[data-role=collapsible-set] div[data-role=collapsible]", function(){
    // your code goes here
});

jsFiddle

于 2013-05-15T02:57:09.023 回答