Last active
January 27, 2017 18:25
-
-
Save aleckyann/bd1ba5a723715bfb239b07e80ec23e2e to your computer and use it in GitHub Desktop.
removeEventListener not work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nulo (event) { | |
return true; | |
} | |
if(sessionStorage.getItem('enterToSend') === 'true'){ | |
document.getElementById('enterToSend').setAttribute('checked', true); | |
document.getElementById('mensagem').addEventListener('keydown', function(e) { | |
if(e.keyCode == 13) { | |
document.getElementById('enviaMensagem').click(); | |
} | |
}); | |
} else { | |
document.getElementById('enterToSend').removeAttribute('checked'); //remove checked do checkbox | |
document.getElementById('mensagem').removeEventListener('keydown', nulo); | |
} | |
function enterToSend(e){ | |
if(sessionStorage.getItem('enterToSend') === 'false'){//Enviar com enter! | |
sessionStorage.setItem('enterToSend', 'true'); | |
document.addEventListener('keydown', function(e){ | |
if(e.keyCode == 13){ | |
document.getElementById('enviaMensagem').click() | |
} | |
}); | |
}else{ | |
document.removeEventListener('keydown', nulo); //remove envento com enter | |
sessionStorage.setItem('enterToSend', 'false'); | |
} | |
} | |
(function initEnterToSend(){ | |
if(sessionStorage.getItem('enterToSend') === null){ | |
sessionStorage.setItem('enterToSend', 'false'); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment