首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Popcorn.js和jQuery

Popcorn.js和jQuery
EN

Stack Overflow用户
提问于 2011-11-15 04:40:24
回答 1查看 1.4K关注 0票数 0

有没有办法使用jQuery来定位Popcorn.js元素。示例:我在下面有一个方法,在文本区有一个div。如果用户不想等待8秒直到元素关闭,我将添加一个关闭跨度来尝试关闭父div。这是在我的script.js中

代码语言:javascript
复制
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‘被点击,然后它的父元素关闭。

这在我的index.html中,在我的script.js下,在脚本标记之间。

代码语言:javascript
复制
$(document).ready(function () {

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

});

HTML元素的布局如下:

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-15 05:56:08

您需要使用事件委托或新的jQuery Live事件处理程序方法来完成此操作,下面是一个示例:http://jsfiddle.net/bcmoney/PTJ4w/ (将爆米花脚注拖到25秒以弹出)

你已经很接近了,但是你忘了说:

代码语言:javascript
复制
<span id="closeWindow" style="float:right; margin-right:10px">Close Window</span>

此外,可能希望将内联CSS移动到外部样式表或至少是标题,但我相信您知道这一点。

最后,jQuery将更改为以下内容:

代码语言:javascript
复制
  $(document).ready(function () {
      $('#closeWindow').live("click", function () {
          $(this).parent().parent().hide();
      });
  });
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8127794

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档