我有如下用的getElementById一个问题:问题与的getElementById
<script type="text/javascript">
<!--
function show_links(locale) {
var box = document.getElementById(locale);
if(box.style.display == "none") {
box.style.display = "inline";
}
else {
box.style.display = "none";
}
}
//-->
</script>
<div class="link"><strong><a href="javascript:show_links(test);">Test</a></strong></div>
<div class="test"> Blah blah blah. This content comes and goes. </div>
所以你有代码。当我点击链接“测试”时,它应该隐藏“等等等等文本”。当再次点击时,它应该显示。但是,我有一个奇怪的问题。我通过调试器处理了代码,看起来var box = document.getElementById(locale);
行不能正常工作。 box
正被设置为空。任何人都可以为什么理论化?
把测试放在引号 – 2009-11-01 02:21:30