I have a div called .dots_menu
that shows up when clicking on .dots
.
I am trying to write a code that hides this div whenever a user clicks on anything else that is not the .dots_menu
div (ex: the background of the page around the div).
This is my HTML part:
<img src="3dots.png" class="dots"/>
<div class="dots_menu">
<a href="#">Install</a>
<a href="#">Add to wishlist</a>
</div>
This is my CSS part:
.dots{
height: 25px;
float: right;
}
.dots_menu{
display: none;
width: 202px;
position: absolute;
top: 40px;
right: 1px;
z-index: 1;
background: rgb(238, 238, 238);
-webkit-box-shadow: 0px 4px 15px #000;
-moz-box-shadow: 0px 4px 15px #000;
box-shadow: 0px 4px 15px #000;
}
.dots_menu.show{
display: block;
}
.dots_menu a {
display: block;
text-decoration: none;
color: #000;
padding: 10px;
font-family: arial;
}
And this is my jQuery that doesn't work:
$('.dots').click(function(){
$('.dots_menu').removeClass('show');
$(this).next().addClass('show');
$(document).one("click",function(){ //
$('.dots_menu').removeClass('show');
});
});