フォーム入力時に TEXTAREA で「Command」+「Enter」でフォーム送信をする

● jquery-textarea-form-submit-cmd-enter.js

jQuery(function($) {
	// add a handler for form submit (makes an AJAX call)
	// OFF $(document).on('submit', 'form.my-class', myFormSubmitHandler);

	// submit form on command + enter if in a textarea
	$(document).on('keydown', 'body', function(e) {
		if (!(e.keyCode == 13 && e.metaKey)) return;

		var $target = $(e.target);
		if ($target.is('textarea')) {
			$target.closest('form').submit();
		}
	});
});

引用 : https://goo.gl/ED8t4r
No.1395
12/15 15:14

edit