自己添加点击事件时,需要的值恰好也是另外标签的ID,这样传过去的竟然是id为那个标签的DOM.解决的方案就是加'',让其变成String
<!DOCTYPE html>
<html>
<head>
<title>测试</title>
</head>
<body>
<div id="test" style="width: 200px;height: 200px;background: red;" οnclick="getDomHaha(haha);">
<p id="haha">hahaahah</p>
</div>
<script type="text/javascript">
function getDomHaha(test){
console.log(typeof(test))
console.log(test);
var pNode = document.getElementById("haha");
console.log(pNode);
}
</script>
</body>
</html>