Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

hide a div when user clicks outside of it

$(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();
    }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: add tailwind to create react app 
Javascript :: javascript sum array of objects by key 
Javascript :: random int javascript 
Javascript :: js invert color 
Javascript :: JS append content into a DOM element 
Javascript :: node redisjson get properties of array object 
Javascript :: ng class in angular 
Javascript :: angular elementref 
Javascript :: es6 loop through object 
Javascript :: vue v-for object 
Javascript :: javascript insert before 
Javascript :: discord bot playing game 
Javascript :: react toastify dark mode 
Javascript :: react run on route change 
Javascript :: redirect with javascript 
Javascript :: javscript foreach with click listener 
Javascript :: javascript assert example 
Javascript :: write own nodemon in package.json 
Javascript :: include jsp in another jsp 
Javascript :: angular load json file with httpclient 
Javascript :: react dictionary key value avec 2 variable 
Javascript :: get nth character of string javascript 
Javascript :: jquery get element innertext 
Javascript :: toggle checkbox in javascript 
Javascript :: How to swap two array elements in JavaScript 
Javascript :: add bootstrap to angular 13 
Javascript :: jquery animation 
Javascript :: javascript check if array has duplicate values 
Javascript :: how to go back to previous page after updating data in jquery 
Javascript :: convert data into json format in javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =