Ajax异步按下回车提交表单

作者:故事我忘了
个人微信公众号:程序猿的月光宝盒

[toc] html
<form id="findInvis">
        帖子标题:
        <input title="请输入帖子标题" name="title">
        <!--input的类型还是submit-->
        <input type="submit" value="搜索" >
</form>

js

/**
 * 点击查找按钮/提交表单,设置提交方法,但是返回false
 */
$("#findInvis").submit(function () {
    //按下回车/提交按钮后的操作
    findBy(1);
    //返回false
    return false;
});

isEmpty()判断input框是否为空

isEmpty:

​ 判断函数入参值是否为空,只能用于字符型(string)、对象(object)、数组(array),

​ 不适用于数值型和布尔型,举例说明:

  1. 空值: null、‘’(空字符串)、undefined 返回都是true 。

    Ex:

    isEmpty(null) ,isEmpty(''), isEmpty(undefined) 判断结果都是true

    2.boolean类型 true、false 返回都是true 。

​ Ex:

isEmpty(true) , isEmpty(false) 判断结果都是true

isEmpty('true') , isEmpty('false') 将参数视为字符串,判断结果都是false

3.number类型 0、1、2 返回都是true

isEmpty(0) , isEmpty(1) , isEmpty(2) 判断结果都是true

isEmpty('0') , isEmpty('1') , isEmpty('2') 判断结果都是false

原文地址:https://www.cnblogs.com/jsccc520/p/12000640.html