iphone不支持點(diǎn)擊document click的解決方法
標(biāo)簽:
JavaScript
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.box{width:100%;height:300px;background:green;position: relative;}
.box a{display:block;width:100%;height:100%;border:1px solid red;}
.child{position:absolute;width:50%;height:500px;background:yellow;display:none;}
</style>
<script class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('.box a').on('click',function(event){
if($('.child').css('display')=='none'){
$('.child').show();
}else{
$('.child').hide();
}
event.stopPropagation();
});
$('.child').on('click touchstart',function(event){
event.stopPropagation();
});
$(document).on('click touchstart',function(){
$('.child').hide();
});
});
</script>
</head>
<body>
<div class="box">
<a>menu1</a>
<div class="child">
fdkslafjkdlsajfkdls
</div>
</div>
</body>
</html>
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫(xiě)下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦