返回顶部、on()绑定事件

$('.back_top').bind('click', function() {

    $("html, body").animate({ scrollTop: 0 }, 200);

});

$('.back_top').bind({click:function() {

    $("html, body").animate({ scrollTop: 0 }, 200)}

});

html返回顶部

 1.<body style='height:3000px;'><div style="position:fixed;bottom:100px;"><a href="#" target="_self">UP</a></div></body>

2.<a style="position:fixed;bottom:10px; left:10px;" onclick="javascript:scroll(0,0)">TOP</a>

<a style="position:fixed;bottom:10px; left:10px;" onclick="window.scroll(0,0)">TOP</a>

 

bind()多个事件EG:

$(document).ready(function(){

  $("button").on({

    click:function(){$("p").slideToggle();},

    mouseover:function(){$("body").css("background-color","red");},  

    mouseout:function(){$("body").css("background-color","#FFFFFF");}  

  });

});

posted @ 2015-04-23 11:31  mrt_yy  阅读(132)  评论(0编辑  收藏  举报