click outside box jquery
$(document).mouseup(function(e)
{
var container = $("YOUR CONTAINER SELECTOR");
// if the target of the click isn't the container nor a descendant of the container
if (!container.is(e.target) && container.has(e.target).length === 0)
{
container.hide();
}
});$(document).click(function(){
$("#try").hide();
});
$("#try").click(function(e){
e.stopPropagation();
});<script>
$(document).mouseup(function(e){
var container = $("#elementID");
// If the target of the click isn't the container
if(!container.is(e.target) && container.has(e.target).length === 0){
container.hide();
}
});
</script><body>
<p id="try">Lorem ipsum is placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts and visual mockups.
</p>
</body>
Also in JavaScript:
- require is not defined javascript
- how to draw a flower in javascript
- json datetime
- angular input press enter
- know if a mobile open the website js
- javascript remove object key
- loop in javascript
- how to get the value of radio button in jquery
- default value of functin atribute
- check radio button is checked jquery
- how to run resize event only on client side angular
- javascript user agent detection
- js how to to attach an event handler only once
- js add item to array
- Get requests return html code instead of real data
- javascript increment
- javascript founder
- reusable table in react js
- queue data structure in javascript 2018
- javascript convert to and from binary
- tobe a number jest
- install javascript kali linux
- js get date in ms
- reqeuest body in hapijs