1

<li>CMS/DB から生成されるアイテムのリストがあります。それぞれ<li><div>、ライトボックスへのリンク (非表示の<div>) を含む があります。リンクは非表示 (#inline-content-print) の ID をターゲットにしている<div>ため、JavaScript プラグインがトリガーされ、ライトボックスがプルアップされます。

私が直面している問題は<li>、ページ上のすべての が同じ非表示divID で生成されることです (これをクラスに変更できます)。そのため、どの<li>href がクリックされても、常に<li>ページの最初 (id の最初のインスタンス) のライトボックスが表示されます。divhref がこれ (クリックされているリンクが存在するもの)から「#inline-content-print を開く」と言う方法が必要です。

<li>
<div class="store-buttons-bg hide-print-buttons-{tag_Hide-Print-Buttons}">

<a href="#inline-content-print" class="various store-button">PRINT</a>

        <div style="display: none;" id="inline-content-print">
        CONTENT OF LIGHTBOX
        </div>
        <!-- end inline-content-print -->

</div>
</li>

アドバイスをいただければ幸いです。

4

2 に答える 2

0

jQuery/Javascript でこれを行いたいと仮定すると、次のようなものを使用できます。

$(document).ready(function()
{
    $('li a.store-button').click(function(e)
    {
        var lightboxElement = $(e.currentTarget).find('div');
        lightboxElement.show(); // or whatever function you need to display
        return false;
    });
});

これは、次のような小さなスクリプトです。

  1. ページがロードされるのを待ちます。
  2. リスト要素を検索します (liオブジェクト タイプとリンク上のクラスによって)
  3. クリック イベントをインターセプトします。
  4. divクリックされたリンクにネストされた要素を検索します。
  5. ターゲットのライトボックス要素に表示 (または別の関数を実行) します。
于 2012-09-30T17:00:45.203 に答える
0

サーバー側の言語は何を使用していますか? これらのリスト項目をループで生成していますか? そのループにインデックスはありますか?もしそうなら、これはあなたのために働くでしょう。

[Server language version of a for loop with an index variable named "i"]
<li>
<div class="store-buttons-bg hide-print-buttons-{tag_Hide-Print-Buttons}">

<a href="#inline-content-print_[server language output of "i"]" class="various store-button">PRINT</a>

        <div style="display: none;" id="inline-content-print_[server language output of "i"]">
        CONTENT OF LIGHTBOX
        </div>
        <!-- end inline-content-print -->

</div>
</li>
[server language version of an end to the for loop]
于 2012-09-13T17:19:44.720 に答える