Created
June 22, 2011 02:16
-
-
Save brandonhilkert/1039388 to your computer and use it in GitHub Desktop.
Submit text in textarea with "Enter"
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 that allows a textarea to use the enter | |
// key to submit the associated form | |
$.fn.submitTextArea = function() { | |
return this.each(function() { | |
$(this).keypress(function(e){ | |
if (e.keyCode == 13 && !e.shiftKey) { | |
e.preventDefault(); | |
$(this).closest('form').submit(); | |
} | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment