0

我需要检查是否单击了按钮,以便您可以使用“if”设置条件

PS:有无限多的元素,每个都有一个旋钮。验证应该是动态的

我的按钮事件:

$(btnClose).click(function () {
     $(this).parent().remove();
     $("#modalProperties").hide();
});

我的点击元素事件:

$(".clonado").live("click",function(){
     $("#modalProperties").show();
});

问题: 这里的问题是元素在 div 内,删除它们后我应该关闭一个模态问题是这个模态是通过单击元素打开的 发生的情况是它打开然后关闭,因为我单击了元素开始操作以关闭和打开模式。

有谁知道可以做什么?

我可以知道这是您第一次开始活动吗?

4

2 回答 2

1

假设问题与冒泡有关,请像这样修复它:

$(btnClose).click(function (event) {
     event.preventDefault();
     $(this).parent().remove();
     $("#modalProperties").hide();
});

$(".clonado").click(function(event){
     event.preventDefault();
     $("#modalProperties").show();
});
于 2013-06-08T12:01:29.347 回答
0

使用 .on 事件并像这样使用 .ready 事件。

$(document).ready(function () {

 $(btnClose).on('click',function () {
   $(this).parent().remove();
   $("#modalProperties").hide();
 });

 $(document).on("click",".clonado",function(){
   $("#modalProperties").show();
 });

});
于 2013-06-08T12:05:35.327 回答