I need an area that when clicked, prevents scroll
of the screen while the cursor is over that area, however, it works normal outside that area.
I have achieved this with a function that I will leave next, but when I click the close button, I need the previous function to be canceled.
$('#el').click(function(){
$(this).on({
'mousewheel': function(e) {
e.preventDefault();
e.stopPropagation();
}
})
});
body {
height: 2700px;
}
#el {
position: relative;
width: 250px;
height: 250px;
background: red;
}
#close {
position:absolute;
color:#fff;
cursor:pointer;
background:rgba(0,0,0,0.3);
right:0;
border:0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id='el'>
<button id='close'>x</button>
</div>