乱码乱a∨中文字幕,在线免费激情视频,亚洲欧美久久夜夜潮,国产在线网址

  1. <sub id="hjl7n"></sub>

    1. <sub id="hjl7n"></sub>

      <legend id="hjl7n"></legend>

      當(dāng)前位置:首頁 >  站長 >  編程技術(shù) >  正文

      jQuery實(shí)現(xiàn)鼠標(biāo)拖拽登錄框移動效果

       2020-11-10 14:31  來源: 腳本之家   我來投稿 撤稿糾錯

        阿里云優(yōu)惠券 先領(lǐng)券再下單

      這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)鼠標(biāo)拖拽登錄框移動效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

      本文實(shí)例為大家分享了jQuery鼠標(biāo)拖拽登錄框移動的具體代碼,供大家參考,具體內(nèi)容如下

      1.jQuery代碼

      <script src="js/jquery-3.5.1.js" type="text/javascript" charset="utf-8"></script>
      <script type="text/javascript">
      $(function () {
      // 點(diǎn)擊登錄跳轉(zhuǎn)
      $("a").click(function () {
      $("#bg,#login").css("display","block");
      })
      // 定義變量
      var $mX;
      var $mY;
      var $move = false; // true是可以移動登錄框
      // 鼠標(biāo)按下事件
      $("#login").mousedown(function (event) {
      $(this).css("opacity",0.5); // 改變透明度
      $move = true;
      // 得到鼠標(biāo)與登錄框原點(diǎn)之間的距離
      $mX = event.pageX-parseInt($(this).css("left"));
      $mY = event.pageY-parseInt($(this).css("top"));
      })
      // 鼠標(biāo)移動事件
      $("#login").mousemove(function (event) {
      if($move){
      // 得到登錄框要移動的量
      $(this).css("left",(event.pageX-$mX)+"px")
      $(this).css("top",(event.pageY-$mY)+"px")
      }
      }).mouseup(function () {
      // 鼠標(biāo)彈起事件
      $move = false;
      $(this).css("opacity",1);
      })
      })
      </script>

      2.css

      <style type="text/css">
      *{
      margin: 0;
      padding: 0;
      }
      h3{
      display: block;
      width: 300px;
      height: 50px;
      text-align: center;
      line-height: 50px;
      background-color: #0076A9;
      }
      #login{
      width: 300px;
      height: 200px;
      margin: 0 auto;
      position: absolute;
      top: 250px;
      left: 500px;
      border: 1px solid #000000;
      background-color: #FFFFFF;
      cursor: move;
      display: none;
      }
      table{
      position: absolute;
      top: 50px;
      left: 0;
      width: 100%;
      height: 150px;
      text-align:center;
      }
      tr,td{
      border: none;
      }
      tr{
      height: 50px;
      }
      td{
      padding: 0 5px 0 5px;
      }
      #bg{
      width: 100%;
      height: 100%;
      background-color:#999999;
      position: absolute;
      top: 0;
      left: 0;
      display: none;
      }
      body{
      width: 100%;
      height: 600px;
      }
      </style>

      3.HTML

      <!DOCTYPE html>
      <html>
      <head>
      <meta charset="utf-8">
      <title>登錄界面</title>

      </head>
      <body>
      <a href="javascript:;" >登錄</a>
      <div id="bg"></div>
      <form action="javascript:;" id="login" method="">
      <h3>歡迎登錄!</h3>
      <table border="1" cellspacing="0" cellpadding="0">
      <tr>
      <td align="right">用戶名:</td>
      <td align="left"><input type="text" name="userName"/></td>
      </tr>
      <tr>
      <td align="right">密碼:</td>
      <td align="left"><input type="password" name="pwd"/></td>
      </tr>
      <tr>
      <td align="center" colspan="2">
      <input type="button" value="提交"/>
      &nbsp&nbsp&nbsp&nbsp&nbsp
      <input type="button" value="重置"/>
      </td>
      </tr>
      </table>
      </form>

      </body>
      </html>

      以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

      來源:腳本之家

      鏈接:https://www.jb51.net/article/195519.htm

      申請創(chuàng)業(yè)報(bào)道,分享創(chuàng)業(yè)好點(diǎn)子。點(diǎn)擊此處,共同探討創(chuàng)業(yè)新機(jī)遇!

      相關(guān)標(biāo)簽
      jquery教程

      相關(guān)文章

      熱門排行

      信息推薦