I would like to know how to check if an array is empty or null in jQuery. I tried array.length === 0
but it didn't work. It did not throw any error either.
This is the code:
var album_text = new Array();
$("input[name='album_text[]']").each(function(){
if( $(this).val() && $(this).val() != '') {
album_text.push($(this).val());
}
});
if (album_text.length === 0) {
$('#error_message').html("Error");
}
else {
// send data
}