這段代碼有什麼問題?我在IE10和Firefox中測試了它,但沒有提出click
事件。爲什麼點擊事件沒有提出?
<html>
<head>
<title>Sandbox</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
#t1, #t2 { border: 2px solid gray; }
#t2 { background-color: pink; }
</style>
<script>
// Function to change the content of t2
function modifyText(new_text) {
var t2 = document.getElementById("t2");
t2.firstChild.nodeValue = new_text;
}
// Function to add event listener to table
var el = document.getElementById("outside");
el.addEventListener("click", function(){modifyText("four")}, false);
</script>
</head>
<body>
<table id="outside">
<tr><td id="t1">one</td></tr>
<tr><td id="t2">two</td></tr>
</table>
</body>
</html>