Jquery method to determine whether it is empty: 1. Use undefined to determine, the code is [if(C==null||C==undefined||C==""){//code}]; 2. To determine the length, the code is [if(C.length==0){//code}].
The operating environment of this tutorial: windows7 system, jquery3.2.1 version, thinkpad t480 computer.
Recommended: jquery video tutorial
##jquery method to determine whether it is empty:
When writing verification, you need to perform verification when the input value is not empty. The code is as followsif($("#email").val()) { var isEmail = /^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; if(!isEmail.test($("#email").val())){ $('#popContent').text('请您输入正确的邮箱'); $('#popMask').modal('open'); return false; } }
var C = $("class name or id").val();
if(C==null||C==undefined||C==""){ //代码 }
if(C.length==0){ //代码 }
if(C){ //代码 }
Related free learning recommendations: javascript(Video)
The above is the detailed content of How to determine if jquery is empty. For more information, please follow other related articles on the PHP Chinese website!