Created
February 6, 2017 16:01
-
-
Save kuznetsovandrey76/f1c5f7d29cf932df375e65161125221e to your computer and use it in GitHub Desktop.
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
// HTML | |
<div id="first" class="content"></div> | |
<div id="second" class="content"></div> | |
//JS | |
var first = document.querySelector("#first"); | |
var second = document.querySelector("#second"); | |
var clickedLink = { | |
first: 0, | |
second: 0 | |
} | |
var click = function(e) { | |
// switch - case | |
if(e.target.id === "first") { | |
clickedLink.first++; | |
} | |
if(e.target.id === "second") { | |
clickedLink.second++; | |
} | |
console.log(clickedLink); | |
} | |
// querySelectorAll | |
first.addEventListener('click', click); | |
second.addEventListener('click', click); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment