There is canvas tag. I have Menu with sub menu on that canvas. When user click on Setting
, sub menu was showed. Sub menu was show over canvas but if i click on sub menu calling canvas click event.
<div id="canvas">
<ul class="toolBarul" id="toolBar">
<li class="toolBarli">
<a class="button" onclick="toggleSetting()">Setting</a>
<ul id="SettingWrap">
<li><input id="rainControl" type="checkbox" onchange="rainControl(this)"><label>rain<span class="chktoc"></span></label></li>
<li><input id="flameControl" type="checkbox" onchange="flameControl(this)" checked="checked"><label>flame<span class="chktoc"></span></label></li>
</ul>
</li>
<li class="toolBarli" style="float: right;padding: 4px;">
<img src="images/Logo.png" />
</li>
</ul>
</div>
#SettingWrap{
display:none;
width: 280px;
height:308px;
top: 100%;
position: absolute;
z-index: 598;
list-style: none;
margin: 0;
padding: 0;
background: rgba(0, 40, 58, 0.91);
padding: 5px;
}
#SettingWrap li {
width: 267px;
height: 40px;
line-height: 40px;
vertical-align: middle;
padding: 5px 10px;
color: #9dd702;
}
According to this article , i write below code but don't work:
$("#SettingWrap").on("mousedown", function (e) {
e.preventDefault();
});
正如@Mosh Feu在评论中所说,我在画布的click
事件之前调用event.stopPropagation()
,它解决了我的问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.