在按钮上更改鼠标光标 - 与指针正常

时间:2015-04-23 13:24:24

标签: javascript css cursor

我在js上创建了一个“右侧滑动菜单”。它工作正常,但是当我将鼠标指向菜单图标时,它会显示一个正常光标(look at the picture in link)。我需要一个没有添加任何链接的指针游标。

#buttonu5815{

      transition-property: top;
      transition-duration: 0.2s;
      transition-timing-function: ease;

      -webkit-transition-property: top;
      -webkit-transition-duration: 0.2s;
      -webkit-transition-timing-function: ease;
   }
var theMenu;
var originLeft;

window.onload = function() {
   //Click to open on the Muse Icon
   element = document.getElementById("buttonu5717");
   element.onclick = openMenu;

   //save the Left position
   originLeft = document.getElementById("buttonu5815").style.top;
   //Get the Menu element
   theMenu = document.getElementById("buttonu5815");

   //Click to close
   closeBtn = document.getElementById("buttonu5822");
   closeBtn.onclick = closeMenu;
}

function openMenu(){
   theMenu.style.top = 0;
}

function closeMenu(){
   theMenu.style.top = originLeft;
}

2 个答案:

答案 0 :(得分:3)

我认为这个CSS就是你要找的。

#buttonu5815:hover {
   cursor:pointer;
}

答案 1 :(得分:0)

您可以在悬停事件中使用CSS实现此目的,只需设置相关的class / html标记(例如,对于li元素):

li:hover {
    cursor: pointer;
}
相关问题