<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#d1{width:100px;height:20px;background: paleturquoise}
#d2{width:40px;height:20px;background: palegoldenrod}
#d3{width:80px;height:20px;background: pink}
</style>
</head>
<body>
<div id="xy">XY</div>
<div id="d1"></div>
<div id="d2"></div>
<div id="d3"></div>
<div id="d4">div4</div>
<a href="http://www.baidu.com">aaa</a>
</body>
<script src="js/jquery-1.11.3.min.js"></script>
<script>
//1.鼠标右键禁用
// $(document).on("contextmenu",function(){
// return false
// });
//2.鼠标键值
$("#xy").mousedown(function(e){
alert(e.which);//1,2,3
//左键1,
//中间2.
//右键3.
});
//3.自定义选择器
var select="widthMroe50px";
$.expr[":"][select]=function(a){
return $(a).width()>50
};
console.log(select);
$("div:widthMroe50px").click(function(){
alert("我大于50px");
});
//4.跳转链接
$("#d4").click(function(){
window.location=$(this).next("a").attr("href");
});
//5.改变this;
//call/apply
var n=10;
function fn(){
console.log(this.n)
}
var obj={
n:"n",
fn:fn
};
obj.fn();//"n"
fn();//10
fn.call(obj)//"n"
// fn();//10->"n"
</script>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#d1{width:100px;height:20px;background: paleturquoise}
#d2{width:40px;height:20px;background: palegoldenrod}
#d3{width:80px;height:20px;background: pink}
</style>
</head>
<body>
<div id="xy">XY</div>
<div id="d1"></div>
<div id="d2"></div>
<div id="d3"></div>
<div id="d4">div4</div>
<a href="http://www.baidu.com">aaa</a>
</body>
<script src="js/jquery-1.11.3.min.js"></script>
<script>
//1.鼠标右键禁用
// $(document).on("contextmenu",function(){
// return false
// });
//2.鼠标键值
$("#xy").mousedown(function(e){
alert(e.which);//1,2,3
//左键1,
//中间2.
//右键3.
});
//3.自定义选择器
var select="widthMroe50px";
$.expr[":"][select]=function(a){
return $(a).width()>50
};
console.log(select);
$("div:widthMroe50px").click(function(){
alert("我大于50px");
});
//4.跳转链接
$("#d4").click(function(){
window.location=$(this).next("a").attr("href");
});
//5.改变this;
//call/apply
var n=10;
function fn(){
console.log(this.n)
}
var obj={
n:"n",
fn:fn
};
obj.fn();//"n"
fn();//10
fn.call(obj)//"n"
// fn();//10->"n"
</script>
</html>