阅读背景:

jQuery实现ctrl+enter(回车)提交表单

来源:互联网 

!--NEWSZW_HZH_BEGIN--

以jQuery插件开发的办法开发。具体代码以下:

jQuery.fn.extend({
  /**
   * ctrl+enter提交表单
   * @param {Function} fn 操作后履行的函数
   * @param {Object} thisObj 指针作用域
   */
  ctrlSubmit:function(fn,thisObj){
    var obj = thisObj || this;
    var stat = false;
    return this.each(function(){
      $(this).keyup(function(event){
        //只按下ctrl情形,期待enter键的按下
        if(event.keyCode == 17){
          stat = true;
          //撤消期待
          setTimeout(function(){
            stat = false;
          },300);
        } 
        if(event.keyCode == 13 && (stat || event.ctrlKey)){
          fn.call(obj,event);
        } 
      });
    });
  } 
});

j




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: