Skip to content

Instantly share code, notes, and snippets.

@IPRIT
Created October 28, 2015 17:03
Show Gist options
  • Select an option

  • Save IPRIT/6b1fb42c0ddb7ec6aa3e to your computer and use it in GitHub Desktop.

Select an option

Save IPRIT/6b1fb42c0ddb7ec6aa3e to your computer and use it in GitHub Desktop.
// 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