Last active
June 14, 2018 14:40
-
-
Save jeangontijo/78e45998eada64afc0b6554d9d7a1a6f to your computer and use it in GitHub Desktop.
Hover on Touch
This file contains 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
// Replace :hover for .hover | |
var card = document.querySelectorAll('.card'); | |
Array.prototype.slice.call(card).forEach(function(item) { | |
item.addEventListener('touchstart', function(e) { | |
this.classList.toggle("hover"); | |
}, false); | |
item.addEventListener('mouseenter', function(e) { | |
this.classList.add("hover"); | |
}, false); | |
item.addEventListener('mouseleave', function(e) { | |
this.classList.remove("hover"); | |
}, false); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment