How to hide or remove div using Escape key from keyboard using JavaScript and jQuery
Using JavaScript
<script type="text/javascript">window.onkeyup = function (event) {if (event.keyCode == 27) {document.getElementById(boxid).style.visibility="hidden";// window.close();}}</script>
Using jQuery
$( document ).on( 'click', function ( e ) {if ( $( e.target ).closest( elem ).length === 0 ) {$( elem ).hide();}});$( document ).on( 'keydown', function ( e ) {if ( e.keyCode === 27 ) { // ESC$( elem ).hide();}});
0 comments :
Feel free to leave comment if you like above widget, have any questions or just say Hi! :)