[英]Why parent element click event fires automatically when child textbox is clicked/focus in Safari?
I have following HTML structure 我有以下HTML结构
[Checkbox] [Text] [Input element (Show if check-box is checked)]
<span class='spGrpContainer'>
<label id='stepGH_Group1' class='lblStep GHSteps lblGroupheader' stepid='1' stepname='Group1' childcontainer='ulGH_grp1Steps'>
<label><input type='checkbox' onchange="Javascript:HideUnHideSubItems();" /><span class='sptext spGHStepName'>Check Me</span></label>
<label class='lblRanking' style='display: none;'><input id='rnkbox_Scr' class='txtImportance' type='number' min='0' max='100' step='1' value='' /></label>
</label>
</span>
When input element click, the checkbox is automatic hide in Safari browser
. 单击输入元素后,该复选框将自动隐藏在
Safari browser
。 In all other major browser like Chrome, IE, Firefox it's working nice. 在所有其他主流浏览器(如Chrome,IE,Firefox)中,它运行良好。 Check Fiddle
检查小提琴
I also tried event.stopPropagation()
for resolving event bubbling, but its didn't helpful. 我也尝试使用
event.stopPropagation()
来解决事件冒泡,但是它没有帮助。 Check Fiddle 检查小提琴
Is there any way to resolve this issue? 有什么办法解决这个问题?
Click is an event that bubbles up. 点击是冒泡的事件。 You might want to take a look at the JavaScript Documentation by MDN about event bubbling.
您可能想看一下MDN的JavaScript文档中有关事件冒泡的信息。 http://javascript.info/tutorial/bubbling-and-capturing
http://javascript.info/tutorial/bubbling-and-capturing
event.stopPropagation()
should prevent it from happening. event.stopPropagation()
应该防止它发生。 Stop propagation documentation 停止传播文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.