e.target 和e.srcElement的区别查了一下百度,说ie用e.srcElement,ff用e.target
为什么我用ie也能使用e.target?
e.target能兼容所有浏览器吗?
下面的代码ie6也没报错
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>page title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="http://localhost/includes/templates/y01/css/stylesheet_010_oocss.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function hello(){
$("#good").click(function (e){
e.preventDefault();
var target= e.target;
alert(target.className=="");
});
}
$(function(){
hello();
});
</script>
</head>
<body>
<div id="good">
<div class="good">good</div>
<div>boy</div>
</div>
<button onclick="hello();">hello</button>
</body>
</html>