原生js实现div点击其他地方隐藏下拉列表
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 window.onload = function() 2 { 3 var aa = true; 4 window.onclick = function() 5 { 6 if(aa) 7 { 8 document.getElementbyId("id1").style.dispaly = "none"; 9 } 10 aa = true; 11 } 12 document.getElementbyId("id2").style.dispaly = function() 13 { 14 aa = false; 15 document.getElementbyId("id1").style.dispaly = "block"; 16 } 17 }