0

それにもかかわらず、私の質問は些細なことかもしれません。

アコーディオンをコンテンツに合わせて設定するには、ドキュメントでは次のように述べています

$( ".selector" ).accordion({ heightStyle: "content" });

要素自体でこれを行うことはできますか? これは私がやりたいことです:

<div id="accordion" style="heightStyle: 'content';" >
4

1 に答える 1

3

いいえ。これはスタイル要素ではなく、jQuery パラメータです。パラメータにより、jQuery accordianライブラリは特定の方法で動作できます。

これは、単に値を変更するだけで実行されるコードの一部です。

if (heightStyle === "fill") {
    maxHeight = parent.height();
    this.element.siblings(":visible").each(function () {
        var elem = $(this),
            position = elem.css("position");

        if (position === "absolute" || position === "fixed") {
            return;
        }
        maxHeight -= elem.outerHeight(true);
    });

    this.headers.each(function () {
        maxHeight -= $(this).outerHeight(true);
    });

    this.headers.next()
        .each(function () {
        $(this).height(Math.max(0, maxHeight -
            $(this).innerHeight() + $(this).height()));
    })
        .css("overflow", "auto");
} else if (heightStyle === "auto") {
    maxHeight = 0;
    this.headers.next()
        .each(function () {
        maxHeight = Math.max(maxHeight, $(this).css("height", "").height());
    })
        .height(maxHeight);
}
于 2013-04-05T22:38:46.523 に答える