所以这段代码有效:
<script>
function animate() {
var x = 0;
var goUp = document.getElementById('rotationUp');
var comeDown = document.getElementById('rotationDown');
goUp.onmouseover = alert(x);
}
</script>
这不会:
<script>
function animate() {
var x = 0;
var goUp = document.getElementById('rotationUp');
var comeDown = document.getElementById('rotationDown');
goUp.onmouseover = function() {
alert(x);
}
}
</script>
唯一的区别是功能,我哪里出错了?
PS:我需要它作为一个函数工作