Posts

Showing posts from February 27, 2014

Preventing form submission when Enter is pressed

$('input').keydown(function(event){             if(event.keyCode == 13) {                 event.preventDefault();                 return false;             } });

How to detect a click outside an element?

Attach a click event to the document body which closes the window. Attach a separate click event to the window which stops propagation to the document body. $('html').click(function() { //Hide the menus if visible }); $('#menuele').click(function(event){     event.stopPropagation(); });