$(this)和event.target之间的区别?
我是jQuery的新手,正在制作选项卡式面板,遵循JavaScript和jQuery教程:The Missing Manual,当作者这样做时,第一行是:
var target = $(this);
但我试着这样做
var target = evt.target;
我得到了那个错误:
Uncaught TypeError: Object http://localhost/tabbedPanels/#panel1 has no method 'attr'
当我改evt.target回去时$(this),它就像一个魅力。
我想知道$(this)和之间的区别是evt.target什么?
这是我的代码,以防您需要它:
index.html:
<!DOCTYPE html><html>
<head>
<title>Tabbed Panel</title>
<style>
body {
width : 100%;
height: 100%;
}
#wrapper {
margin : auto;
width : 800px;
}
#tabsContainer {
overflow: hidden;
}
#tabs {
padding:0;
margin:0;
}
#tabs li {
float : left;
list-style:none;
}
#tabs a {
text-decoration:none;
padding : 3px 5px;
display : block;
}
#tabs a.active {
background-color : grey;
}
#panelsContainer {
clear: left;
}
#panel1 {
color : blue;
}
#panel2 {
color : yellow;
}
#panel3 {
color: green;
}
#panel4 {
color : black;
}
</style>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>慕尼黑的夜晚无繁华
相关分类