我的锚点-快速定位
菜单事件
$('body').contextmenu(function(event){
console.log("常用于禁止右键菜单查看源码");// 右键菜单弹出
// return false;
// 禁止元素的默认动作,例如禁止右键菜单,禁止超链接,禁止form表单的提交
event.preventDefault();
});
鼠标进出事件
$('div').hover(
function(){
// mouseenter
this.innerText = "hover:mouseenter";
},
function(){
// mouseleave
this.innerText = "hover:mouseleave";
}
);
mouseenter: function(){
this.style.width = "170px";
this.style.height = "220px";
this.innerText = "mouseenter";
},
mouseleave: function(){
this.style.width = "150px";
this.style.height = "200px";
this.innerText = "mouseleave";
},
keydown和keypress键盘事件
$('#username').keypress(function(e){
// ASCI码
console.log("keypress:" + String.fromCharCode(e.which) );
console.log('keypress(key方式):' + e.key );
});
$('#username').keydown(function(e){
// 键盘代码, shit alt ctrl等不会产生字符的按键只有keydown可以触发
console.log("keydown:" + e.which );
});
focusin和focusout光标事件
窗口文档事件 load / ready
$(document).ready(function(){
// 相当于 $(function(){ });
});