Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 76102

I cannot get .toggleClass to work for some reason. Shopping list assignment using Jquery [closed]

$
0
0

The add and remove functions are working, but the "check" function which contains .toggleClass is not working. Any help would be greatly appreciated. I'm putting a link to the code below. Here is the line where I believe the problem lies. I am going to enter a snippet of the js in this question as well.

Javascript:

$(".shopping-list").on("click", ".shopping-item-toggle", function(event) {
  event.preventDefault();
  $(this).closest('li').find(".shopping-item").toggleClass('.shopping-item__checked');
});

The CSS class which the function should toggle:

.shopping-item__checked {
   text-decoration: line-through;
}

My code so far on Repl.it.


Viewing all articles
Browse latest Browse all 76102

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>