📜  hover vanilla javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:43.548000             🧑  作者: Mango

代码示例1
var target = document.querySelector(".button");
target.addEventListener("mouseover", mOver, false);
target.addEventListener("mouseout", mOut, false);

function mOver() {
   target.setAttribute("style", "background-color:blue;")
}

function mOut() {  
   target.setAttribute("style", "background-color:green;")
}