0

jQueryを使用してPopcorn.js要素をターゲットにする方法はありますか?例:テキスト領域にdivを含むメソッドとして以下に示します。要素が閉じるまで8秒間待ちたくない場合は、親divを閉じようとするクローズスパンを追加しています。これは私のscript.jsにあります

example.popupFootnote({ "id": "footnote",
    "start": 2,
    "end": 10,
    "target": "footnotes",
    "title": "Tear Gas",
    "text": '<div id="exampleBox"><span style="float:right; margin-right:10px">Close Window</span><a href="http://en.wikipedia.org/wiki/Tear_gas">Tear gas</a>, formally known as a lachrymatory agent or lachrymator (from lacrima meaning "a tear" in Latin), is a non-lethal chemical compound that stimulates the corneal nerves in the eyes to cause tearing, pain, and even blindness. Common lachrymators include OC, CS, CR, CN, nonivamide, bromoacetone, phenacyl bromide, xylyl bromide and syn-propanethial-S-oxide (from onions). Lacrymators often share the structural element Z=C-C-X, where Z indicates carbon or oxygen, and X indicates bromide or chloride.</div>',
    top: '10%',
    left: '70%'
});`

したがって、要素「closeWindow」をクリックしてから、その親のボックスを閉じると、それは必要ありません。

これは、スクリプトタグ間のHTMLのscript.jsの下にあるindex.htmlにあります。

$(document).ready(function () {

    $('#closeWindow').click(function () {
        $(this).parent().parent().hide();
    });

});

HTML要素は次のようにレイアウトされます。

<div id="movieHolder">

<div id="video" style="width: 750px; height: 422px;" ></div>

    <div id="overlayDiv"></div>

    <div id="overlayDiv-Map"></div>

    <div id="footnotes"></div>

</div>
4

1 に答える 1

2

これを行うには、Event Delegation または新しいjQuery Liveイベント ハンドラー メソッドを使用する必要があります。例を次に示します: http://jsfiddle.net/bcmoney/PTJ4w/ (ポップコーンの脚注がポップアップするまで 25 秒スクラブします)

あなたはかなり近かったが、実際に置くのを忘れていた:

<span id="closeWindow" style="float:right; margin-right:10px">Close Window</span>

また、インライン CSS を外部スタイルシートまたは少なくともヘッダーに移動したい場合もありますが、それはご存知だと思います。

最後に、jQuery は次のように変更されます。

  $(document).ready(function () {
      $('#closeWindow').live("click", function () {
          $(this).parent().parent().hide();
      });
  });
于 2011-11-14T21:56:08.190 に答える