addRevealHandler函数中onclick的内容为什么没有执行
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
.reveal *{display: none;}
.reveal *.handle{display: block;}
</style>
<script type="text/javascript">
window.onload = function () {
var elements = document.getElementsByClassName('reveal');
for (var i = 0; i < elements.length; i++) {
var elt = elements[i];
var title = elt.getElementsByClassName('handle')[0];
addRevealHandler(title,elt);
}
function addRevealHandler(title,elt) {
title.onClick =
function() {
if(elt.className == "reveal") {
elt.className = "revealed";
}else if(elt.className == "revealed") {
elt.className = "reveal";
}
};
}
};
</script>
</head>
<body>
<div class="reveal">
<h1 class="handle">点击显示隐藏文本</h1>
<p>此段落隐藏,请点击标题显示隐藏文本</p>
</div>
</body>
</html>
------解决方案--------------------title.onClick title.onclick
------解决方案--------------------正确的写法:注意不是所有的浏览器都支持 getElementsByClassName方法
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
.reveal *
{
display: none;
}
.reveal *.handle
{
display: block;
&nb