Within the code snippet, a function is present which performs the following actions.
It searches for an email in the input field, then converts the email to an md5 hash, and finally generates a Gravatar URL that is inserted into a class using fadeIn();
$(document).ready(function(){ $('.email').on('change', function(){ var hash = hex_md5($('.email').val()); $('.gravatar').attr('src', 'http://www.gravatar.com/avatar/' + hash + '?s=120').addClass('gravatar-glow').fadeIn("slow"); }); }); HTML Part: <img src="" class="gravatar" style="display: none;"/>
The issue at hand
- If the email is removed from the input field, the class still remains visible but now displaying the default Gravatar image instead of the md5 hashed one.
The desired outcome is to hide the previously used class when the input field is empty, such as when a user decides to delete their email to use a different one, rather than showing the Default Gravatar image.
Below is the jQuery code implementation: