Hello all.
I have a grid which shows every image of every project/subpage I have. I want a function which says that as soon as an image is clicked, that every other image has an opacity of 0.3, except every image of that specific project.
Its driving me a bit crazy for a while, because I can’t figuring out how to add classes to these images.
Would be super nice if someone could help me. Thank you very much in advance.
Is the script in the top of the html file or the bottom? Some scripts ned to be at the bottom because they look up the page to find the element. Also, is it inside a document ready?
The reason why it didn’t work is because you have an additional classname on the element, so the string replacement doesn’t work. Solution that should now work, but only after removing the whitespace after the lazyload class:
<script>
$(".item").on( "click", function() {
var className = $(this).attr('class');
var elements = $("." + className.replace(/ /g,'.'));
elements.addClass("itemSelector");
});
</script>