编辑:我需要提及的是我不想使用 jQuery。
这是我的代码。我需要访问触发事件的元素,这样我就不必为每个 html 元素创建两个不同的函数。
document.getElementById("login").onmouseover = turnWhite;
function turnWhite(e){
}
我可能需要这样的东西。不知道是否可行。
function turnWhite(e){
e.HTMLEL.style.color = "white";
}
这可能吗?
最佳答案
- Internet Explorer 中的 e.srcElement
- 大多数其他浏览器中的 e.target。
关于javascript - 我可以在JavaScript中的事件触发函数中获取html元素吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15303321/