我的 html 结构是这个样子的,设置了 input 的隐藏
<div class="qr-btn" node-type="qr-btn">扫描二维码1
<input node-type="jsbridge" type="file" name="myPhoto" value="扫描二维码1" />
</div>
比如我的代码是这个样子的
//父级元素为 tempBtn
$(tempBtn).on('click',function(e){
//触发子元素的一个 input元素的 click
$(this).find('[node-type=jsbridge]').click();
return false;
});
如果这样子的话,会无限次的去触发子元素的事件,因为发生了冒泡,但是这种形式,怎么组织子元素事件的冒泡啊
试过这样子写也是不管用的
$(tempBtn).bind('click',function(e){
$(this).find('[node-type=jsbridge]').click(function(e){
return false;
});
});
为子元素添加click的处理事件,事件函数里加阻止冒泡的代码