js判断input输入的字符串是否为空或者空格 var str = ''; if ((typeof str === 'string') && (str.trim() === '')) { console.log('str 为空或者空格!') }