gpt4 book ai didi

javascript - jQuery 漂亮照片 : Click event doen't work

转载 作者:行者123 更新时间:2023-12-02 19:39:24 24 4
gpt4 key购买 nike

我一直在使用 jQuery prettyPhoto显示内联 html 内容的插件。此内容有一个链接,该链接应该关闭 PrettyPhoto 弹出窗口并调用自定义脚本。弹出窗口工作正常,但不知何故链接的单击事件没有被触发。这是代码。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<title>Development</title>
<script src="js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="js/jquery.prettyPhoto.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css"/>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("#closeme").click( function (e){
e.preventDefault();
alert("closing popup");
$.prettyPhoto().close();
alert("do some othe stuff");
});

$("a[rel^='prettyPhoto']").prettyPhoto();

});
</script>
</head>
<body>
<a href="#inline-1" rel="prettyPhoto" >popop</a>
<div id="inline-1" style="display:none;">
<p>This is inline content opened in prettyPhoto.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<a href="#" id="closeme">close</a>
</div>
</body>
</html>

如果我删除 $("a[rel^='prettyPhoto']").prettyPhoto(); 然后单击内联 html 链接上的事件就可以正常工作。

有人可以帮我找出问题并解决它吗?

谢谢,阿米特·帕特尔

最佳答案

按如下方式修改您的代码:

$(function () {
$("a[rel^='prettyPhoto']").prettyPhoto();
$('#closeme').live('click', function() {
$.prettyPhoto.close();
return false;
});
});

关于javascript - jQuery 漂亮照片 : Click event doen't work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10581992/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com