Is there a way to hide an entire <div>
if a profile image is missing, while keeping the other <div>
with the same class visible? I've tried creating a solution in my jsfiddle, but I'm not sure if it's correct. Can someone verify?
I need this functionality to be implemented within the CSS/JS page of a closed system (Springshare/LibGuides), so I can't include any inline calls or similar methods.
$(() => {
var src = $('img').attr('src');
if (src === '//libapps.s3.amazonaws.com/apps/common/images/profile.jpg'){
$('.s-lib-featured-profile-container').hide();
}
else {
$('.s-lib-featured-profile-container').show();
}
})
<div class="s-lib-featured-profile-container"><a href="/prf.php?account_id=127256">
<div class="s-lib-featured-profile-image">
<img src="//libapps.s3.amazonaws.com/apps/common/images/profile.jpg" alt="Julie Brewer's picture">
</div>
<div class="s-lib-profile-div s-lib-featured-profile-name">Julie Brewer</div></a>
</div>
<div class="s-lib-featured-profile-container"><a href="/prf.php?account_id=131922">
<div class="s-lib-featured-profile-image">
<img src="//libapps.s3.amazonaws.com/accounts/131922/profiles/125264/Caldwell_John.jpg" alt="John Caldwell's picture">
</div>
<div class="s-lib-profile-div s-lib-featured-profile-name">John Caldwell</div></a>
</div>
For more information, please refer to the jsfiddle example:
https://jsfiddle.net/Raser/nq5swa10/3/
The goal is for the code to utilize the img
and src
attributes to hide the
<div class="s-lib-featured-profile-container">
containing "Julie Brewer" and show the one containing "John Caldwell".
Thank you for any help!