$(this)和event.target之間的區(qū)別?我是jQuery的新手,正在制作選項(xiàng)卡式面板,遵循JavaScript和jQuery教程:The Missing Manual,當(dāng)作者這樣做時(shí),第一行是: var target = $(this);但我試著這樣做 var target = evt.target;我得到了那個(gè)錯(cuò)誤:Uncaught TypeError: Object http://localhost/tabbedPanels/#panel1 has no method 'attr'當(dāng)我改evt.target回去時(shí)$(this),它就像一個(gè)魅力。我想知道$(this)和之間的區(qū)別是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>
$(this)和event.target之間的區(qū)別?
慕桂英3389331
2019-08-15 15:53:02