标签:
<!DOCTYPE html>
<html class="index">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=yes" />
<title>jQuery.mmenu demo</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<div id="test"> js</div>
<div id="jquery"> jquery</div>
<div>e.target是html对象,html对象转字符串直接变成[object HTMLDivElement]。所以要获取htmldom的话用event.target.innerHTML等</div>
<div>console.log()能打印object对象,所以log看到了值。造成假象。</div>
</body>
<script type="text/javascript">
document.getElementById("test").onclick = function(e){
console.log(e.target);
console.log("ddd"+e.target);
}
$("#jquery").click(function(e){
console.log("ddd"+e.target);
var obj = {id:"dis",name:"name"};
console.log("my"+obj);
var s = e.target;
alert(s);
});
</script>
</html>
单击<div>js</div> log值:
<div id="test"> js</div>
ddd[object HTMLDivElement]
标签:
原文地址:http://www.cnblogs.com/FnuJava/p/4689323.html