gpt4 book ai didi

JQuery Flippy 插件未在点击事件上触发

转载 作者:行者123 更新时间:2023-12-01 04:13:33 26 4
gpt4 key购买 nike

我在使用 jQuery Flippy 插件时遇到 flippy 插件标签的小问题 http://blog.guilhemmarty.com/flippy/

我有一个带有 p 标签的 div

<div id="divID">
<p id="pID" class="someClass">Some text
<a id="aID" href="#">Some text</a> </p>
</div>

我的页面上的事件处理程序

$("#aID").click(function(){
var content = $("#divID").html();
$("#divID").flippy({
direction:"LEFT",
duration: "500",
verso: content

});
});

问题是,当我单击要翻转 div 的元素时,div 会翻转,但单击函数不会处理另一次单击。

我只能翻转 div 一次。当我将“a”元素放在 div 外部时,我可以随意翻转,但这不是我的目标。

有人可以给我建议吗?

最佳答案

因为我在div中注册的所有事件监听器在翻转div后都不可用,所以我在翻转后再次注册这个监听器

$(document).on("click", "#element", function(){ do something});

即:

在我的 JSP 中: `$(document).ready(function() {

$("#register").click(function() {
switchRegister();

});

$("#forgPass").click(function() {
forgPass();
});

});`

在 .js 文件中:

/* * 将登录界面切换至注册界面 */

函数 switchRegister() { var mainContent = $("#LoginBox").html();

$("#btnLogIn").prop('value', regText);
$("#regProfile").hide();
$("#regPass").hide();

$("#iconName").show();
$("#regText").show();
$("#goBack").show();

var content = $("#LoginBox").html();

$("#LoginBox").flippy({
direction:"LEFT",
duration: "500",
verso: content,
onFinish: function() {
$("#goBack").on("click", function(){
$("#LoginBox").empty();
backToLogin(mainContent, "right");
});
}
});

}

/* * 返回登录屏幕 */

函数 backToLogin(内容,方向) {

if(direction == "right") {
console.log("direction RIGHT");
$("#LoginBox").flippy({
direction:"RIGHT",
duration: "500",
verso: content,
onFinish: function(){
$(document).on("click", "#register", function(){
switchRegister();
});
$(document).on("click", "#forgPass", function(){
forgPass();
});
}
});
} else {
console.log(" direction Bottom");
$("#LoginBox").flippy({
direction:"BOTTOM",
duration: "500",
verso: content,
onFinish: function(){
$("#register").on("click", function(){
switchRegister();
});
$("#forgPass").on("click", function(){
forgPass();
});
}
});
}

}

/* * 忘记密码 */函数 forgPass() {

var mainContent = $("#LoginBox").html();

$("#btnLogIn").prop('value', passText);
$("#regPass").hide();
$("#regProfile").hide();
$("#iconPass").hide();
$("#regText").hide();
$("#goBack").show();

var content = $("#LoginBox").html();

$("#LoginBox").flippy({
direction:"TOP",
duration: "500",
verso: content,
onFinish: function() {
$("#goBack").on("click", function(){
$("#LoginBox").empty();
backToLogin(mainContent, "bottom");
});
}
});

}

关于JQuery Flippy 插件未在点击事件上触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17290395/

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