Skip to content

Instantly share code, notes, and snippets.

@yangjunjun
Last active December 31, 2015 14:29
Show Gist options
  • Save yangjunjun/8000898 to your computer and use it in GitHub Desktop.
Save yangjunjun/8000898 to your computer and use it in GitHub Desktop.
一些 jQuery代码片段。
//禁止右键菜单
$(document).bind("contextmenu", function(){
return false;
});
//捕获回车事件
$(document).keydown(function(event){
if(event.keyCode==13){
console.log('Enter ');
}
});
//JS触发回车事件
var e = jQuery.Event("keydown");
e.keyCode = 13;
$(document).trigger(e);
// 回到顶部
$('body').scrollTop(0); //没有动画效果
$('body').animate({scrollTop:0},1000) // 有动画效果
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment