Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery中的冲突事件处理_Jquery - Fatal编程技术网

jQuery中的冲突事件处理

jQuery中的冲突事件处理,jquery,Jquery,我有这样一个: <div id="Field1"> <label id="label1">Name</label><br/> <input type="text" data-attr="text" style="..." id="input1"/><br/> <label id="instr1"/> <div class="xfb-row-options1"> <a cl

我有这样一个

<div id="Field1">
  <label id="label1">Name</label><br/>
  <input type="text" data-attr="text" style="..." id="input1"/><br/>
  <label id="instr1"/>
  <div class="xfb-row-options1">
    <a class="button-delete" src="..." style="...">-</a> 
  </div>
</div>
我有一个
,里面有一个“删除”图像按钮,我想点击“
button-delete1
”删除它。我试了一下:

$("#fb_contentarea_col1down21 div div .button-delete1").live("click", function(){
  //deleting the Div Field1
  return false;
});
现在我的两个功能都冲突了。当我单击“
button-delete1
”时,我的函数#1将被执行并显示一个错误。

使用该方法删除div,并防止删除按钮上的单击事件触发父div上的单击事件:

  $("#fb_contentarea_col1down21 div div .button-delete1").live("click", function(e){
      e.stopPropagation();
      $("#Field1").remove();
      return false;
  });
使用该方法删除该div,并避免导致delete按钮上的click事件触发父div上的click事件:

  $("#fb_contentarea_col1down21 div div .button-delete1").live("click", function(e){
      e.stopPropagation();
      $("#Field1").remove();
      return false;
  });