【jQuery】请教一个事件问题 在注册一个鼠标移出事件onmouseout 执行和 mouseup 一样 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我是覺得能不用js就不用js樓主提供的正確的示例應該是用css而已:hover{ background-position: 0px -122px;}:active{ background-position: 0px -244px;} 因为你的mousedown和mouseup是注册在某个元素上的 当移出这个元素时就不触发这个元素的mouseup了啊<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript">window.onload=function(){ var div=document.getElementById('test'); div.onmousedown=function(){ div.style.backgroundColor='black'; } document.body.onmouseup=function(){ div.style.backgroundColor='red'; }}</script></head><body><div id="test" style="width:400px; height:400px; background-color:#F00"></div></body></html>onmouseup注册到父元素上试试 用js怎么读取sms格式文件 求救Js效果~~ 怎么把文本框中的内容保存成html文件? 如何在点击一个链接以后,显示一个层,这个层的左边为链接的第一个文字位置,顶部为链接的底部? 高分:那位高手有用脚本写的报表表单的源码?/ 可以使flash只播放前30秒就再次从头开始吗? 除了我不会,谁都会的简单问题 很容易得分的问题 谁能解决这个问题,现金300元感谢,绝不食言 新手求助!javascript写省市联动求代码错在哪了? jquery easy ui combobox function()参数问题 jquery 动态添加input 一级和二级
:hover{
background-position: 0px -122px;
}
:active{
background-position: 0px -244px;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload=function(){
var div=document.getElementById('test');
div.onmousedown=function(){
div.style.backgroundColor='black';
}
document.body.onmouseup=function(){
div.style.backgroundColor='red';
}
}
</script>
</head><body>
<div id="test" style="width:400px; height:400px; background-color:#F00"></div>
</body>
</html>onmouseup注册到父元素上试试