我正在写javascript,它将在鼠标悬停在其上时更改元素的颜色。我完全知道如何使用jQuery来做到这一点,但这一次我使用有使用纯JS或Prototype来做到这一点。使用javascript更改元素onMouseOver的颜色
为什么不这项工作:
<div id="boundary1"></div>
document.getElementById("boundary1").onmouseover(function() {
alert("test");
})
萤火虫返回:
TypeError: document.getElementById(...).onmouseover is not a function
有没有诀窍,你是一个bauss – Ortix92
@ Ortix92:请标记为接受的答案,如果它为你工作。 :) –
我还得等上几分钟。有没有办法将选定的元素传递给该函数? – Ortix92