Created
October 28, 2015 17:03
-
-
Save IPRIT/6b1fb42c0ddb7ec6aa3e to your computer and use it in GitHub Desktop.
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
| // your code goes here. | |
| var element = document.querySelector('.block'); | |
| var ball = document.querySelectorAll('.ball'); | |
| var count = 0; | |
| function fn (e) { | |
| var coords = { | |
| x: 0, | |
| y: 0 | |
| }; | |
| coords.x = e.x; | |
| coords.y = e.y; | |
| for (var i = 0; i < ball.length; ++i) { | |
| ball[i].style.top = coords.y + 'px'; | |
| ball[i].style.left = coords.x + 'px'; | |
| } | |
| } | |
| element.addEventListener('click', fn, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment