Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In jquery ui doc , there is method by index to activate accordion.
However I want to activate from "accordion found".
What must be replaced by ??? in code below, or any other solution

var accordion = $('.ui-accordion')   

accordion.each(function () {
    var hashHref = $.param.fragment(); //hashHref is the anchor href of relevant accordion
    $(this).find("a[href='#" + hashHref + "']").???;                
});

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
144 views
Welcome To Ask or Share your Answers For Others

1 Answer

with the help of this answer, this solves the case:

  accordion.each(function () {
    var hashHref = $.param.fragment();
    var findElement = $(this).find("a[href='#" + hashHref + "']");
    if (findElement.length) {
        var ndx = $(findElement).parent().index() * 0.5;
        $(this).accordion("activate", ndx);
    }
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...