码迷,mamicode.com
首页 > Web开发 > 详细

jQuery事件

时间:2016-09-09 18:41:07      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

$(function(){

  $(‘*‘).each(function(){

    var current = this;

    this.addEventListener(‘click‘,function(event){

      say(‘Capture for ‘ + current.tagName + ‘#‘ + current.id + ‘target is‘ + event.target.id)  

    },true);

    

    this.addEventListener(‘click‘,function(event){

      say(‘Bubble for ‘ + current.tagName + ‘#‘ + current.id + ‘target is‘ + event.target.id)  

    },false)

    function say(text){

      $(‘#console‘).append(‘<div>‘+text+‘</div>‘);

    }

  })

})

<body id=‘greatgrandpa‘>

  <div id=‘grandpa‘>

    <div id=‘pops‘>

    <img id=‘vstar‘ src=‘vster.jpg‘/>

    </div>

  </div>

  <div id=‘console‘></div>

</body>

技术分享

其实这个图已经可以看出一些东西了 事件在不同处理阶段通过DOM树的传播情况

=========================================================

关于事件

JQ 我自己推荐

input改变 用change()

其他的可以on  当然on绑定前 需要off解绑

-----------------------------------------------------------------------------------------

写一个有点用的动画 页面上从上向下模拟下坠动画

$(‘‘).each(function(){

  $(this).animate({

    opacity:0;

    top:$(window).height() - $(this).height() - $(this).position().top

  },‘slow‘,function(){ $(this).hide(); })

})

 

基本也就是这样了 好像。。。so  先噶

 

jQuery事件

标签:

原文地址:http://www.cnblogs.com/wulibo/p/5857349.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!