去掉子元素继承于父元素的事件

来源:互联网 发布:用ps做淘宝店长图 编辑:程序博客网 时间:2024/06/10 01:59
去掉子元素继承于父元素的事件,只需要在子元素的函数结束的时候返回false
这样整个函数就会认为返回失败,就不会再走父元素的函数。

例如:

<dl class="select"><dt id="DSelect"><i><input id="org_in" value="a"/></i><em></em></dt><dd id="Dtree" class="dtree"></dd></dl>//父元素的绑定监听//下拉菜单$("#DSelect").on("click",function(ev){ev.stopPropagation();$(this).next("dd").stop().slideToggle();});//子元素绑定监听$("#DSelect em").on("click",function(){var param={};param["obj/ORG_NAME"]=$("#org_in").val();$.post('com.pns.panoramicwh.panwh.querylocation.biz.ext',param,function(result){if(result.rows.length>0){var lat=result.rows[0].LATITUDE;//维度var lon=result.rows[0].LONGITUDE;//经度$("#org_in").val(result.rows[0].ORG_NAME);//WhMgt.ShowWHPos(result.rows[0].ORGNO);//加载单位下的点frm_mapView.MapManage.redirect(lon,lat);}else{alert('没有地理位置');return;}});});//这样如果点击子元素的话,只要不报错,会连带着父元素的绑定函数一块执行;//现在如果不想执行父元素的函数,只需要在子元素的函数结束的位置增加return//false,即可//子元素绑定监听$("#DSelect em").on("click",function(){var param={};param["obj/ORG_NAME"]=$("#org_in").val();$.post('com.ds.panoramicwh.panwh.querylocation.biz.ext',param,function(result){if(result.rows.length>0){var lat=result.rows[0].LATITUDE;//维度var lon=result.rows[0].LONGITUDE;//经度$("#org_in").val(result.rows[0].ORG_NAME);//WhMgt.ShowWHPos(result.rows[0].ORGNO);//加载单位下的点frm_mapView.MapManage.redirect(lon,lat);}else{alert('没有地理位置');return;}});return false;});


0 0
原创粉丝点击