jquery判断输入框的字符串是否为空或者空格

function checkKey(key) {
  if($.trim(key) == ''){
    /**
     * 输入的字符串为空,空格
     */
    alert('请输入关键字');
    return false;
  }else{
    /**
     * 输入的字符串为
     */
    return true;
  }
}

 

$.trim(key)   相当于python3中的str.strip()

 

转自:https://www.cnblogs.com/handsomeBoys/p/6767459.html

posted @ 2020-07-16 10:26  月月coding  阅读(2017)  评论(0)    收藏  举报