I'm currently facing an issue on a website that requires a solution involving jQuery/javascript, which I am not proficient in.
After the page loads, javascript is executed which renders various html/css elements. The specific portion we are focusing on appears like this:
<div class="profile-list">
<a class="profile-profile" href="https://website.com/?profile=joe_blogs_337#show_more">Add loads of html</a>
<a class="profile-profile" href="https://website.com/?profile=sam_smith_292#show_more">Add loads of html</a>
<a class="profile-profile" href="https://website.com/?profile=john_doe_31#show_more">Add loads of html</a>
<a class="profile-profile" href="https://website.com/?profile=stack_overflow_17#show_more">Add loads of html</a>
</div>
We only want to display certain profiles and ignore any that do not match our criteria.
I've attempted using CSS to hide individual profiles like so:
a.profile-profile[href$='?profile=stack_overflow_17#show_more'] {
display: none !important;
}
I can also hide all profiles except one with the following code:
a.profile-profile:not([href$='?profile=stack_overflow_17#show_more']) {
display: none !important;
}
However, when I try to hide all profiles except two, they all end up hidden...
a.profile-profile:not([href$='?profile=stack_overflow_17#show_more']), a.profile-profile:not([href$='?profile=john_doe_31#show_more']) {
display: none !important;
}
Since CSS doesn't seem to be the answer, I'm seeking a quick javascript solution...
Is there a way to detect when the external js script runs so that it can modify the rendered HTML swiftly?
Instead of globally hiding all links and then selectively showing some, I'd prefer to find a more targeted approach using jQuery/Javascript.