有没有办法使用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‘被点击,然后它的父元素关闭。
这在我的index.html中,在我的script.js下,在脚本标记之间。
$(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>发布于 2011-11-15 05:56:08
您需要使用事件委托或新的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();
});
});https://stackoverflow.com/questions/8127794
复制相似问题