I have a block of code that looks like this:
//Account Number
account = $(msg).find('[name=account_number]').val();
if(account){
$('#progressUpdates').append('<span class="glyphicon glyphicon-ok"></span> Found Account Number<br />');
}else{
$( '#progressUpdates').append('<span class="glyphicon glyphicon-remove"></span> Account Number not found<br />');
}
The problem is, if the element that is being assigned to account doesn't exist, it throws an error. I tried doing :
if(account.length){}
But the issue isn't with the if statement, its assigning the variable. Is there a better solution to this?