zoukankan      html  css  js  c++  java
  • VQuery高级特性

    VQuery高级特性

    css方法

              同时设置多个--for in

               链式操作

    链式操作

             函数,链式操作

             css 方法链式操作

             json的使用

    阻止冒泡,默认事件

    VQuery插件

     插件机制

           可以扩展库的功能

     extend

            为VQuery添加方法

             原型

    实例

             animate---动画

                    else
                    {
                        iCur=parseInt(getStyle(obj, attr));
                    }
                    
                    //2.算速度
                    var iSpeed=(json[attr]-iCur)/8;
                    iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);
                    
                    //3.检测停止
                    if(iCur!=json[attr])
                    {
                        bStop=false;
                    }
                    
                    if(attr=='opacity')
                    {
                        obj.style.filter='alpha(opacity:'+(iCur+iSpeed)+')';
                        obj.style.opacity=(iCur+iSpeed)/100;
                    }
                    else
                    {
                        obj.style[attr]=iCur+iSpeed+'px';
                    }
                }
                
                if(bStop)
                {
                    clearInterval(obj.timer);
                    
                    if(fn)
                    {
                        fn();
                    }
                }
            }, 30)
        }
    });
    运动的的封装.js
    <!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>
    <style>
    #div1 {100px; height:100px; background:red; filter:alpha(opacity: 30); opacity:0.3;}
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script src="jquery-1.7.1.js"></script>
    <script>
    $(function (){
        $('#div1').hover(function (){
            $(this).animate({ '200px', height: '200px', opacity: 1});
        }, function (){
            $(this).animate({ '100px', height: '100px', opacity: 0.3});
        });
    });
    </script>
    </head>
    
    <body>
    运动的实例

              drag---拖拽

    $().extend('drag', function (){
        var i=0;
        
        for(i=0;i<this.elements.length;i++)
        {
            drag(this.elements[i]);
        }
        
        function drag(oDiv)
        {
            oDiv.onmousedown=function (ev)
            {
                var oEvent=ev||event;
                var disX=oEvent.clientX-oDiv.offsetLeft;
                var disY=oEvent.clientY-oDiv.offsetTop;
                
                document.onmousemove=function (ev)
                {
                    var oEvent=ev||event;
                    
                    oDiv.style.left=oEvent.clientX-disX+'px';
                    oDiv.style.top=oEvent.clientY-disY+'px';
                };
                
                document.onmouseup=function ()
                {
                    document.onmousemove=null;
                    document.onmouseup=null;
                };
            };
        }
    });
    vquery拖拽的封装
    <!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>
    <style>
    div {100px; height:100px; background:red; position:absolute;}
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script src="VQuery.js"></script>
    <script src="VQuery_drag.js"></script>
    <script>
    $(function (){
        $('div').drag();
    });
    </script>
    </head>
    
    <body>
    拖拽的应用
  • 相关阅读:
    Asp.net如何连接SQL Server2000数据库
    是男人,都可以看看这个
    体验Flash MX(8):控制时钟Timer
    好代码
    sql 大数据量插入优化
    Xcode 真机程序发布测试
    Xcode 真机程序发布测试
    用git备份代码
    sql 大数据量插入优化
    UIView学习笔记
  • 原文地址:https://www.cnblogs.com/hack-ing/p/5621462.html
Copyright © 2011-2022 走看看