[英]cursor: mouse grab javascript
I have two images: one with an open hand, and one with a grabbing hand. 我有两张图片:一张张开手,另一张用抓手。 I was hoping that a simple "onmousedown" and "onmouseup" functions help to make the famous grabbing hand you can see in something like google maps.
我希望有一个简单的“ onmousedown”和“ onmouseup”功能可以使您在Google地图等事物中看到著名的抓手。 BUT... Sorry, from the beginning: I have a simple DIV with nothing in, apart his background.
但是...很抱歉,从一开始:除了他的背景之外,我只有一个简单的DIV,一无所有。 when I hold down the mouse and start to "drag" the cursor a function is supposed to start and change the cursor form "hand open" to "hand grab".
当我按住鼠标并开始“拖动”光标时,应该启动一个函数并将光标形式从“手动打开”更改为“手动抓取”。 But the cursor become a selector for text istead of what I want.
但是光标变成了文本的选择器,而不是我想要的。 Any help?
有什么帮助吗? this is the example
这是例子
<div onmousedown="function(){this.style.cursor='url(handgrab.png)'}"
onmouseup="function(){this.style.cursor='url(handopen.png)'}"
</div>
the only thing I want is change the cursor when dragging the mouse into the DIV. 我唯一想要的就是将鼠标拖动到DIV中时更改光标。 sorry for this inline choose, but I don't want write all the JS file...
抱歉,此内联选择,但我不想编写所有JS文件...
You should access this through class name. 您应该通过类名访问它。 It makes life easier.
它使生活更轻松。
Try this way:- 尝试这种方式:-
<div onmouseup="this.className='openHand'" onmousedown="this.className='closeHand'">
Mouse Down and Up Events
</div>
.openHand {
cursor: url(https://mail.google.com/mail/images/2/openhand.cur), default !important;
}
.closeHand {
cursor: url(https://mail.google.com/mail/images/2/closedhand.cur), default !important;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.