Blame view
resources/views/js/cookies.blade.php
603 Bytes
bb21d1ccb Суббота работа на... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<script> // cookies const cookieItems = document.querySelectorAll(".js-ck"); if (cookieItems.length) { cookieItems.forEach(item => { let id = item.dataset.id; let like = item.querySelector(".like"); let checkLike = function () { if (like.classList.contains("active")) { Cookies.set(id, id); } else { Cookies.remove(id); } } like.addEventListener("click", () => { checkLike(); }); if (Cookies.get(id) == id) { like.classList.add("active"); } }); } console.log(Cookies.get()); </script> |