I've got a simple function that can either return a match found or no match found result.
If no match is found I want it to display a generic "no user found" image. The below code works fine, but I want to do this the right way. This link
Show/hide image with JavaScript
seems to discuss a far more complex way of achieving what I'm doing.
But is my method incorrect?
JS
success: function (friendMatches) {
if (friendMatches.length === 0)
console.log('NO MATCH FOUND!!!');
$(".no_user").show();
else // Query executed with success
console.log('MATCH FOUND!!!');
},
HTML
<img style="display:none" src="/img/no-user.png" class ="no_user" alt="No user found">