if (!a) {
// is emtpy
}
To ignore white space for strings:
if (!a.trim()) {
// is empty or whitespace
}
If you need legacy support (IE8-) for trim()
, use $.trim
or a polyfill.
More Related Contents:
- Why is my javascript not working
- event.preventDefault() vs. return false
- Inserting a text where cursor is using Javascript/jquery
- JavaScript: filter() for Objects
- jQuery click / toggle between two functions
- jQuery.parseJSON throws “Invalid JSON” error due to escaped single quote in JSON
- Force browser to download image files on click
- Event detect when css property changed using Jquery
- Using jQuery to replace one tag with another
- jQuery: load txt file and insert into div
- How to copy text from a div to clipboard
- How to send data in request body with a GET when using jQuery $.ajax()
- How can I detect with JavaScript/jQuery if the user is currently active on the page?
- Setting CSS value limits of the window scrolling animation
- Focus next input once reaching maxlength value
- capturing f5 keypress event in javascript using window.event.keyCode in window.onbeforeunload event is always 0 and not 116
- Preload mp3 file in queue to avoid any delay in playing the next file in queue
- How to know if JQuery has finished loading [duplicate]
- How to check if an element is in the view of the user with jquery
- Dynamically adding cases to a switch
- How can I make a button redirect my page to another page? [duplicate]
- jQuery .on(‘change’, function() {} not triggering for dynamically created inputs
- jQuery get html of container including the container itself
- Get the content (text) of an URL after Javascript has run with PHP
- Change placeholder text
- Take User Back to Where They Scrolled to on previous page when clicking Browser Back Button
- Fire oninput event with jQuery
- Queue AJAX calls
- What is the difference between $(document).ready(function() and $(function() ?
- How to post ASP.NET MVC Ajax form using JavaScript rather than submit button