I am trying to make what it seemed originally as a simple exercise, a spin wheel. But it turned out far more frustrating than what I was expecting. So i googled how to make one and my code was pretty similar to what I found, yet mine didn't work and the JSFiddle Example seemed to work.
So next thing I did is delete everything I had and copy and paste the JSFiddle. But guess what? It didn't work. Here it is the JSFiddle http://jsfiddle.net/YNBxz/2/
I added an alert to see if it would even enter the function, and it didn't even enter the function. The code seems alright and in JSFiddle it also works.
var img = document.querySelector('img');
img.addEventListener('click', onClick, false);
function onClick() {
alert('ALERT ME');
this.removeAttribute('style');
var deg = 500 + Math.round(Math.random() * 500);
var css = 'transform: rotate(' + deg + 'deg);';
this.setAttribute('style', css);
}
Sorry if in some parts where unclear, I tend to over complicate stuff from time to time.
<img>'s on your page? If so, that could be messing your code up