任何人都知道为什么这在Firefox中不起作用?
<script type="text/javascript">
function goHo() {
hu.innerHTML="????";
}
</script>
<div class="contentPane" id="Calculator" style="display: block;">
<h2>Savings Calculator</h2><a href="Home" class="backArrow"></a>
<h3>How much do you spend on heating and hot water a year?</h3>
<div id="SpendOptions">
<ul class="optionList">
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£60-180'"><li id="CostOption1">£600 - £900</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£90-240'"><li id="CostOption2">£900 - £1200</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£120-300'"><li id="CostOption3">£1200 - £1500</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£150-360'"><li id="CostOption4">£1500 - £1800</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£360'"><li id="CostOption5">£1800+</li></a>
</ul>
</div>
<div id="SavingsBox" style="display: block;">
<h4>This year you could save:</h4>
<h1 id="hu"></h1>
</div>
答案 0 :(得分:5)
hu
应为document.getElementById("hu")
。 (仅仅因为一个项目有一个ID,这并不意味着它将是一个声明的变量(id和作为变量的存在与彼此没什么关系))
答案 1 :(得分:1)
尝试:
function goHo() {
document.getElementById('hu').innerHTML="????";
}
答案 2 :(得分:0)
你需要使用 document.getElementById('hu')。innerHTML =“???”
答案 3 :(得分:0)
你也可以说:
<a href="#" onMouseOut="goHo('????')" onMouseOver="goHo('£60-180')">...
function goHo(html) {
document.getElementById('hu').innerHTML=html;
}