使用javascript和较少的css调试onMouseOver和onMouseOut

使用javascript和较少的css调试onMouseOver和onMouseOut,javascript,html,less,Javascript,Html,Less,我在这里遇到了一些问题,无法找到我的错误。调试控制台说:“找不到变量:mouseover/mouseout。”我不知道她想对我说什么。我想通过onmouseover/onmouseout事件将一个具有较少SCSS的div淡入50%透明度 <div id="right" class="" onMouseOver="javascript: mouseover(this);" onMouseOut="javascript: mouseout(this);"></div> &l

我在这里遇到了一些问题,无法找到我的错误。调试控制台说:“找不到变量:mouseover/mouseout。”我不知道她想对我说什么。我想通过onmouseover/onmouseout事件将一个具有较少SCSS的div淡入50%透明度

<div id="right" class="" onMouseOver="javascript: mouseover(this);" onMouseOut="javascript: mouseout(this);"></div>

<script type="text/javascript">
  function mouseover(this) {
    this.setAttribute("class", "mouseover");
  }

  function mouseout(this) {
    this.setAttribute("class", "");
  }
</script>

您不需要javascript函数,请使用CSS选择器“hover”:

您的div只需将“right”作为id:


#right {
  position:fixed;
  top:320px;
  right:0px;
  z-index:5;
  height:200px;
  width:30px;
  background-image: url(images/right);
  border-radius:5px;
  background-color:fade(darken(@bg-color, 50%),50%);
  cursor:pointer;
}
.mouseover {
  background-color:darken(@bg-color, 50%);
}
#right {
position:fixed;
top:320px;
right:0px;
z-index:5;
height:200px;
width:30px;
background-image: url(images/right);
border-radius:5px;
background-color:fade(darken(@bg-color, 50%),50%);
cursor:pointer;
}
#right:hover {
background-color:darken(@bg-color, 50%);
}
<div id="right"></div>