I have two chain mouse events:
$('body > form').on("mousedown", function(e){
}).on("mouseup", function(){
});
However, when I try to execute off()them as from another external function, I can only off() mousedown, but not mouseup, whose functionality continues to work.
Can this nested addEventListenerprevent me from disabling its event? (
By the way, it doesn’t matter how I chain: ( $().off().off();) or unchain ( $().off(); $().off();) or combine ( $().off(A B);) or vice versa (AB ↔ BA) elements; off(mousedown)works consistently , but never off(up).
Here is my full JS code:
(The problematic part is the second script, at the end :)
<script>
function comment() {
$('body > form').on("mousedown.markerPlacer", function(e){
var newComment2 = $('<div id="newComm" class="marker" class="deg45" ↑</div>');
$('form').append(newComment2);
}).on("mouseup", function(){
window.addEventListener("keydown", extraKey, false);
window.addEventListener("keyup", keysReleased2, false);
function extraKey(e) {
var deg = e.keyCode;
if (deg == 81) {
$('#newComm').attr('class', 'marker').addClass('deg0');
} else {
return false;
};
e.preventDefault();
};
function keysReleased2(e) {
e.keyCode = false;
};
});
};
</script>
<script>
function dismissComment() {
$('body > form').off("mousedown mouseup");
}
</script>