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

您需要使用事件委托或新的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 回答