zoukankan      html  css  js  c++  java
  • js中回车触发事件

    方法一:

    document.onkeydown = function (e) { // 回车提交表单
    // 兼容FF和IE和Opera
        var theEvent = window.event || e;
        var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
        if (code == 13) {
            queryInfo();
        }
    }

    方法二:

    JS监听某个DIV区域

    $("#queryTable").bind("keydown",function(e){
      // 兼容FF和IE和Opera
      var theEvent = e || window.event;
      var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
       if (code == 13) {
      //回车执行查询
      $("#queryButton").click();
      }
    });

    JS监听某个输入框

    //回车事件绑定
    $('#search_input').bind('keyup', function(event) {
      if (event.keyCode == "13") {
        //回车执行查询
        $('#search_button').click();
      }
    });

    原文出处:

    真是你, js中回车触发事件, https://www.cnblogs.com/xulz/p/9208615.html

  • 相关阅读:
    231. Power of Two
    204. Count Primes
    205. Isomorphic Strings
    203. Remove Linked List Elements
    179. Largest Number
    922. Sort Array By Parity II
    350. Intersection of Two Arrays II
    242. Valid Anagram
    164. Maximum Gap
    147. Insertion Sort List
  • 原文地址:https://www.cnblogs.com/ryelqy/p/12518929.html
Copyright © 2011-2022 走看看