JQuery implements ctrl + enter (press enter) to submit Form _ jquery

Source: Internet
Author: User
This article describes how to directly press Ctrl + Enter to submit the form implementation program after we Enter the content. this method is generally used in textarea. other input fields are not required. Developed using jQuery plug-ins. The code is as follows:

JQuery. fn. extend ({/*** ctrl + enter submit form * @ param {Function} the Function executed after the fn operation * @ param {Object} thisObj pointer scope */ctrlSubmit: function (fn, thisObj) {var obj = thisObj | this; var stat = false; return this. each (function () {$ (this ). keyup (function (event) {// Only Press ctrl, wait for the enter key to press if (event. keyCode = 17) {stat = true; // cancel waiting for setTimeout (function () {stat = false ;}, 300) ;}if (event. keyCode = 13 & (stat | event. ctrlKey) {fn. call (obj, event );}});});}});

Usage:

$ ("# Textarea"). ctrlSubmit (function (event) {// submit the code here });

Is it very simple and practical? I hope everyone will like it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.