Last active
December 31, 2015 14:29
-
-
Save yangjunjun/8000898 to your computer and use it in GitHub Desktop.
一些 jQuery代码片段。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//禁止右键菜单 | |
$(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