How to Check Undefined, Empty and Null in JQuery?
If you are working on jquery and However you want to check variable is undefined or not then you can easily check by typeof operator, which is simple, fast and cross-platform:
if(typeof i == "undefined"){
alert('undefined');
}
If you are working on jquery and However you want to check variable is empty or not then you can easily check by compare with empty string:
if(i == ''){
alert('Empty');
}
If you are working on jquery and However you want to check variable is null or not then you can easily check by compare with "null":
if(i == null || i == NULL){
alert('null');
}
Try this......
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- JQuery Remove All Numbers from String Example
- How to Download File using JQuery?
- How to use Laravel Variable in JQuery?
- Laravel JQuery UI Autocomplete Ajax Search Example
- How to Remove Last Element from Array in JQuery?
- Preview an image before Upload using jQuery Example
- JQuery Delete Confirm Modal using Bootbox Example
- How to access PHP variables in JQuery?
- How to Allow Only One Checkbox Checked at a Time in JQuery?
- How to Convert Line Breaks to br in jQuery ?
- How to Check Object is Empty or Not in JQuery?