自己添加點擊事件時,需要的值恰好也是另外標籤的ID,這樣傳過去的竟然是id爲那個標籤的DOM.解決的方案就是加'',讓其變成String
<!DOCTYPE html>
<html>
<head>
<title>測試</title>
</head>
<body>
<div id="test" style="width: 200px;height: 200px;background: red;" onclick="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>