I have a bunch of images that match a list containing their names. When you click on an image, the image disappears, and then the data item finds its corresponding name in the list, then crosses it out in red and changes the word of the list item to gray. I have code, but it does not work or does not cause any errors in the console. I am new to jQuery.
How can I associate a clicked image with the correct list name and then change the font color to gray and give it a different color (red) punch? I would like to revive the punch, but it can be too complicated. Advice is welcome :)
Any help is appreciated!
Here is the code snippet:
CSS
.stroked {
text-decoration: line-through;
color: red;
}
.found {
color: #282828!important;
}
HTML
<div class="picItem" data-item="Dart">
<img src="Dart.png" />
</div>
<div class="picItem" data-item="Dice">
<img src="Dice.png" />
</div>
<div class="itemWrapper">
<ul class="itemList">
<li class="olive">Olive</li>
<li class="dart">Dart</li>
<li class="dice">Dice</li>
</ul>
</div>
Js
$('.picItem').on('click', function () {
strikeThrough($(this).data('item'));
$(this).fadeOut(400, function () {
});
});
function strikeThrough() {
if ($('.itemList li').hasClass('stroked')) {
return;
} else {
$(this).addClass('stroked');
$(this).addClass('found');
}
}