专家!我的问题是优化IE 8的这个代码(IE 8的第一个按钮没问题,但第二个按钮不起作用),谷歌Chrome(第二个按钮没问题,但首先不起作用)。我已经堆叠了,请帮忙。 :)
第一个按钮
<div id="spoiler">
<div>
<p style="text-align: center;"><input style="margin: 10px; padding: 0px; width: 150px; font-size: 12px; background-color: #fdeaa8;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display = ''; this.parentNode.parentNode.getElementsByTagName('div')['hide'].style.display = 'none'; this.innerText = ''; this.value = 'hide spoiler'; } else { this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display = 'none'; this.parentNode.parentNode.getElementsByTagName('div')['hide'].style.display = ''; this.innerText = ''; this.value = Show again?'; }" type="button" value="Elaya company" /></p>
<div>
<div id="show" style="border-style: solid; border-width: 1px; margin: 0px; padding: 4px; display: none; background-color: transparent; width: 98%;">
</div>
第二个按钮
<div id="spoiler">
<div>
<p style="text-align: center;"><input style="margin: 10px; padding: 0px; width: 150px; font-size: 12px; background-color: #fdeaa8;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display = ''; this.parentNode.parentNode.getElementsByTagName('div')['hide'].style.display = 'none'; this.innerText = ''; this.value = 'Hide spoiler'; } else { this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display = 'none'; this.parentNode.parentNode.getElementsByTagName('div')['hide'].style.display = ''; this.innerText = ''; this.value = 'Show again?'; }" type="button" value="AssolModa company" /></p>
<div id="show" style="border-style: solid; border-width: 1px; margin: 0px; padding: 4px; display: none; background-color: transparent; width: 98%;">
答案 0 :(得分:0)
这是您的代码的直接引用吗?因为检查它,我可以立即看到在按钮1的JavaScript代码中,在this.value = Show again?';
(应该是this.value = 'Show again?';
)附近有一个'缺失'。考虑修复它,看看是否有任何变化。