js的this指向
<!doctype html>
<html lang="en">
<head>
<title>this指向</title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<input type="text" id="test" onclick="test()"/>
<input type="text" id="bind" />
</body>
<script>
function test(){
alert("test: " + this);
}
$("#bind").click(function(){
alert("bind: " + this);
});
</script>
</html>
如图
结论
function定义的指向window对象。
$().click()绑定的指向的是绑定的对象。