zoukankan      html  css  js  c++  java
  • jQuery滑动并响应事件

    jQuery滑动并打开指定页面:

    <!DOCTYPE html>
    <html>
    <head>
    <script src="http://code.jquery.com/jquery-1.11.1.min.js">
    </script>
    <script> 
    $(document).ready(function(){
      $(".a").click(function(){
        $(".a").animate({left:'250px'},function(){location.href="http://www.baidu.com"});
      });
    });
    </script> 
    </head>
     
    <body>
    <p>默认情况下,所有 HTML 元素的位置都是静态的,并且无法移动。如需对位置进行操作,记得首先把元
    
    素的 CSS position 属性设置为 relative、fixed 或 absolute。</p>
    <h3>点击方块执行</h3>
    <div class='a' style="background:#98bf21;height:100px;100px;position:absolute;">
    </div>
    
    </body>
    </html>
    View Code

    jQuery来回滑动并响应事件:

    <!DOCTYPE html>
    <html>
    <head>
    <script src="jquery/jquery.js">
    </script>
    <script> 
    $(document).ready(function(){
      $("#box").toggle(function(){
        $("#box").animate({left:'200px'},function(){alert('Slide to the right');}).text('ON');},
        function(){
        $("#box").animate({left:''},function(){alert('Sliding to the left');}).text('OFF');}
      );
    });
    </script> 
    </head>
    
    <body>
    <p>默认情况下,所有 HTML 元素的位置都是静态的,并且无法移动。如需对位置进行操作,记得首先把元素的 CSS position 属性设置为 relative、fixed 或 absolute。</p>
    <h3>点击方块执行</h3>
    <div id='box' style="background:#98bf21;height:100px;100px;position:absolute;">OFF
    </div>
    
    </body>
    </html>
    View Code

     jQuery下载:http://files.cnblogs.com/liuswi/jquery.js

  • 相关阅读:
    压缩流GZipStream
    委托和事件
    .NET垃圾回收机制
    程序集相关知识
    生活
    poj 3767 I Wanna Go Home
    fw:Python GUI的设计工具
    How to configure an NTP client and server on CentOS/RedHat
    FW:Tripwire
    Bash if 判断 集合
  • 原文地址:https://www.cnblogs.com/liuswi/p/3825201.html
Copyright © 2011-2022 走看看