javascript - How to hide div when user clicks other place -
i need hide div id = sdwn when user clicks other place in document.
<div id="sdwn" onclick="okijuyg()"> <img src="../img/lupa.png" id="ildsib" onclick="okijuyga()" > </div> <div id="atsimd"> <div class="arrow-up" id="shs"> </div> <div id="vsauceisgenius" tabindex="-1" > <img src="../img/x.png" id="ctso" href="#"> <input type="text" placeholder="people" id="imohd"> <input type="submit" value="search" id="dpmm"> <p></p> <input type="text" placeholder="hashtags" id="imohds"> <input type="submit" value="search" id="dpmmm"> </div> </div>
you can use event.target check if element clicked, , if not, hide it:
$(document).click(function(event) { if (event.target !== $("#atsimd") && event.target !== $("#shs") { $("#atsimd").hide(); } });
Comments
Post a Comment