gpt4 book ai didi

javascript - 点击显示答案

转载 作者:行者123 更新时间:2023-11-30 16:30:03 25 4
gpt4 key购买 nike

已更新以包含更多代码

我们的网页设计师中风了,我一直在努力在他不在的情况下完成一些设计。看来他永远也帮不了我了。

我一直在使用打字机,其中一个页面有常见问题解答并使用 javascript,这样如果您单击一个问题,就会显示答案。然后,如果您单击答案文本,它会再次消失。我更新了一些答案文本,它似乎以某种方式破坏了 javascript 链接。我一直在做教程并尝试学习如何修复它。它现在只显示问题和答案,点击显示功能已丢失。

我们的设计师使用的是 onclick = toggle

我在此处包含了代码(为简洁起见,将答案文本替换为答案 1),看看是否有人可以指出它是如何损坏的/我该如何修复它。可悲的是,我这样做的经验为零。非常感谢:)

<p>FAQ Display</p>
<script type="text/javascript">// <![CDATA[
function toggle(Info) {
var CState = document.getElementById(Info);
CState.style.display = (CState.style.display != 'block')
? 'block' : 'none';}
// ]]></script>
<div><strong>Click on the question to reveal the answer!</strong><br /><br /></div>
<h3>Services</h3>
<div class="FAQ" onclick="toggle('faq17')"><strong>Why use this service? </strong>
<div id="faq17" class="FAA">Answer 17.</div>
</div>
<div class="FAQ" onclick="toggle('faq1')"><strong>How much does the cleaning and labelling service cost?</strong>
<div id="faq1" class="FAA">Answer 1.</div>
</div>
<div class="FAQ" onclick="toggle('faq2')"><strong>How do I book the service? </strong>
<div id="faq2" class="FAA">Answer 2.</div>
</div>
<div class="FAQ" onclick="toggle('faq3')"><strong>How long does the service take?</strong>
<div id="faq3" class="FAA">Answer 3.</div>
</div>
<div class="FAQ" onclick="toggle('faq4')"><strong>Is there a minimum number of residents required to visit my facility?</strong>
<div id="faq4" class="FAA">Answer 4.</div>
</div>
<h3>DIY Kits</h3>
<div class="FAQ" onclick="toggle('faq5')"><strong>Where can I purchase a kit from?</strong>
<div id="faq5" class="FAA">Answer 5.</div>
</div>
<div class="FAQ" onclick="toggle('faq6')"><strong>How much does a DIY kit cost?</strong>
<div id="faq6" class="FAA">Answer 6.</div>
</div>
<div class="FAQ" onclick="toggle('faq7')"><strong>How long will my kit last? </strong>
<div id="faq7" class="FAA">Answer 7.</div>
</div>
<div class="FAQ" onclick="toggle('faq8')"><strong>Do the kits expire?</strong>
<div id="faq8" class="FAA">Answer 8.</div>
</div>
<div class="FAQ" onclick="toggle('faq9')"><strong>Is there a material data safety sheet (SDS) for the kits?</strong>
<div id="faq9" class="FAA">Answer 9.&nbsp; <span class="asset asset-generic at-xid-6a01b7c6f66688970b01bb088843a0970d img-responsive"><a href="http://www.identoz.com.au/files/sds-identoz-denture-marking-sealant-version-1.0.pdf">Download SDS iDentOz Denture Marking Sealant Version 1.0</a> </span></div>
</div>
<h3>Generic Questions</h3>
<div class="FAQ" onclick="toggle('faq10')"><strong>Where is the label placed on the denture?</strong>
<div id="faq10" class="FAA">Answer 10.</div>
</div>
<div class="FAQ" onclick="toggle('faq11')"><strong>Do you service all areas? </strong>
<div id="faq11" class="FAA">Answer 11.</div>
</div>
<div class="FAQ" onclick="toggle('faq12')"><strong>How do I make payment? </strong>
<div id="faq12" class="FAA">Answer 12.</div>
</div>
<div class="FAQ" onclick="toggle('faq13')"><strong>Are our staff police checked?</strong>
<div id="faq13" class="FAA">Answer 13.</div>
</div>
<div class="FAQ" onclick="toggle('faq14')"><strong>Is your work guaranteed?</strong>
<div id="faq14" class="FAA">Answer 14.</div>
</div>
<div class="FAQ" onclick="toggle('faq15')"><strong>Do you repair dentures? </strong>
<div id="faq15" class="FAA">Answer 15.</div>
</div>
<div class="FAQ" onclick="toggle('faq16')"><strong>Do you have insurance? </strong>
<div id="faq16" class="FAA">Answer 16.</div>
</div>
<p><hr class="at-page-break" /></p>

最佳答案

不是为了支持你想要的东西,但这可能对你有用:

<html><head>
<script type="Text/JavaScript"> function displayanswer(){
document.getElementById('question').innerHTML = ' //Put answer here'}
</script>

</head><body>
<h1>Press on the question for answer</h1>
<button onclick="displayanswer"><h2 id="question"> //put your question here </h2></button>
</body></html>

关于javascript - 点击显示答案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33447554/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com