亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

這個鼠標放到一個位置就一直在動

<!DOCTYPE html>

<html>


<head>

? ? <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

? ? <title></title>

? ? <style>

? ? div {

? ? ? ? width: 500px;

? ? ? ? height: 50px;

? ? ? ? padding: 5px;

? ? ? ? margin: 5px;

? ? ? ? float: left;

? ? ? ? border: 1px solid #ccc;

? ? ? ??

? ? }

? ??

? ? .left {

? ? ? ? background: #bbffaa;

? ? }

? ? button{

? ? ? ? width:200px;

? ? ? ? height:100px;

? ? }

? ? #q1{

? ? ? ? top:200px;

? ? }

? ? #q2{

? ? ? ? top:160px;

? ? }

? ? .right {

? ? ? ? background: yellow;

? ? ? ? display: none;

? ? }

? ? </style>

? ? <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>

</head>


<body>

? ? <h2>通過toggle切換顯示與隱藏</h2>

? ? <div class="left">顯示到隱藏</div>

? ? <div class="right">隱藏到顯示</div>

? ? <button id="q1">直接show-hide動畫</button>

? ? <button id="q2">直接hide-show動畫</button>

? ? <script type="text/javascript">

? ? $("button:first").mousemove(function() {

? ? ? ? $(".left").toggle({

? ? ? ? ? ? ? ? duration:3000,

? ? ? ? ? ? ? ? complete:function(){

? ? ? ? ? ? ? ? ? ? $(this).css('width','800px'

? ? ? ? ? ? ? ? ? ? )

? ? ? ? ? ? ? ? }

? ? ? ? ? ? })

? ? });

? ? </script>


? ? <script type="text/javascript">

? ? $("button:last").mousemove(function() {

? ? ? ? $(".right").toggle(3000)

? ? });

? ? </script>


</body>


</html>


正在回答

2 回答

兩種方法解決此問題 ?第一種 ?把你需要操作的button進行固定定位放在你需要的地方 ?第二種 ?mousemove換成mouseover就會只執行一次?

0 回復 有任何疑惑可以回復我~

事件在一次一次的累加 ?所以如果你鼠標觸發了button:first的事件但是沒有及時移開的話 ?div.left每移動一像素button:first就會觸發一次 ?你的mousemove事件在排隊執行

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

這個鼠標放到一個位置就一直在動

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號