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 {width: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({width: '200px', height: '200px', opacity: 1});
    }, function (){
        $(this).animate({width: '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 {width: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>
拖拽的应用

 

转载于:https://www.cnblogs.com/hack-ing/p/5621462.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值