jquery點擊div以外的地區觸發事件

來源:互聯網
上載者:User

標籤:display   color   des   min   get   cti   html   http   nbsp   

 1 <html>  2 <head>  3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  4 <title>網頁特效展示中心</title>  5 <style type="text/css">  6 #testa,#testa2{position:relative;} 7 #pop,#pop2 { width:100px; height:130px; position:absolute; left:0px; top:20px; border:solid red 1px;background:white; z-index:9999;}  8 </style>  9 </head>10 11 <body> 12 <script type="text/javascript" src="cxx/jquery.min.js"></script> 13 <script type="text/javascript"> 14 function toggle(id)15 {16 var id = document.getElementById(id);17 if(id.style.display == ‘none‘)18 {19 id.style.display = ‘block‘20 }21 else22 {23 id.style.display = ‘none‘;24 }25 }26 27 function dealBlankDivHide(e, id ,destinationid)28 {29 var target = $(e.target); 30 if(target.closest("#"+id).length == 0){ 31 var id = document.getElementById(destinationid);32 if(id.style.display == ‘block‘)33 {34 id.style.display = ‘none‘35 }36 } 37 }38 39 $(function(){ 40 $(document).bind("click",function(e){ 41 dealBlankDivHide(e, ‘testa‘,‘pop‘);42 dealBlankDivHide(e, ‘testa2‘,‘pop2‘);43 }) 44 })45 46 47 </script> 48 <span id="testa">49 <a onclick="toggle(‘pop‘)">onclick</a>50 <div id="pop" style="display:none;">51 <input type="checkbox" name = "test1"/>test152 <input type="checkbox" name = "test2"/>test253 <input type="checkbox" name = "test3"/>test354 <input type="checkbox" name = "test4"/>test455 <input type="checkbox" name = "test5"/>test556 </div> 57 <span>58 <span id="testa2">59 <a onclick="toggle(‘pop2‘)">onclick</a>60 <div id="pop2" style="display:none;">61 <input type="checkbox" name = "test1"/>test1162 <input type="checkbox" name = "test2"/>test2263 <input type="checkbox" name = "test3"/>test3364 <input type="checkbox" name = "test4"/>test4465 <input type="checkbox" name = "test5"/>test5566 </div> 67 <span>68 </br>69 fsdfsdfsfsfsdfsfddf</br>70 fsdfsdfsfsfsdfsfddf</br>71 fsdfsdfsfsfsdfsfddf</br>72 fsdfsdfsfsfsdfsfddf</br>73 fsdfsdfsfsfsdfsfddf</br>74 fsdfsdfsfsfsdfsfddf</br>75 76 77 </body> 78 </html>

 

jquery點擊div以外的地區觸發事件

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.