Last active
November 27, 2020 13:58
-
-
Save adhadse/0a3194c4dc2f1725ed0207a61869aa4e to your computer and use it in GitHub Desktop.
using javascript to search the element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('load',function () { | |
console.log('Loaded') | |
let wislistBtns = document.querySelectorAll('.update-wishlist') | |
if (wislistBtns) { | |
for (let i = 0; i < wislistBtns.length; i++) { | |
wislistBtns[i].addEventListener('click', function () { | |
const productID = this.dataset.product | |
const action = this.dataset.action | |
console.log('productID:', productID, 'Action:', action) | |
if (user === 'AnonymousUser') { | |
console.log('User is Anonymous') | |
} else { | |
updateUserWishlist(productID, action) | |
} | |
}) | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment