Home >Web Front-end >JS Tutorial >How to judge empty string in jquery
The method of judging the empty string in jquery: 1. Judge by judging whether the length of the string is 0; 2. Judge by judging whether the string is equal to null, undefined, etc. The code is [if(str ==null||str==undefined||str=="")].
The operating environment of this tutorial: windows7 system, jquery3.2.1 version. This method is suitable for all brands of computers.
How to judge the empty string in jquery:
1. By judging whether the length of the string is 0
if(str.length==0){ //代码 }
2. By Determine whether the string is equal to null, undefined, etc.
if(str==null||str==undefined||str==""){ //代码 }
Related free learning recommendations: javascript (video)
The above is the detailed content of How to judge empty string in jquery. For more information, please follow other related articles on the PHP Chinese website!