gpt4 book ai didi

javascript:反向显示不工作

转载 作者:行者123 更新时间:2023-12-03 09:28:16 24 4
gpt4 key购买 nike

我有一个使用 javascript:ReverseDisplay 的页面。它突然停止工作了。我不是一个精通 javascript 的人,所以我想知道是否有人可以帮助我找出问题所在。这是页面:http://www.smbgc.org/about/volunteer/

这是页面底部的可折叠 div 之一和脚本:

<div id="youth" class="bluelink" style="padding-bottom: 50px;">
<a href="javascript:ReverseDisplay('youthinfo')">
<span style="font-weight: 800; font-size: 24px;">Youth Volunteers</span>
</a>
<span>Youth volunteers are high school students who are interested in giving back to their community while learning meaningful leadership and job skills. <strong>Youth volunteers are valuable role models for younger members and often are assisting them with programs, homework, & sports in addition to special planned activities by our Teen staff.</strong></span>
<a href="javascript:ReverseDisplay('youthinfo')">
<strong>Click to learn more!</strong>
</a>
<div id="youthinfo" class="bluelink" style="display: none; padding-left: 30px;">
&nbsp; All <strong>Youth Volunteers</strong> must be a current member of the Boys & Girls Clubs of Santa Monica or commit to volunteer for 30 hours within a 3 month period.
To become a member, <a href="http://www.smbgc.org/about/join/">click here</a>.
Youth Volunteers are enrolled in our Leaders in Training Program, and report to the <strong>Director of Volunteer Services, Jessica Rubecindo</strong>.
All participants in the LIT program are expected to attend a weekly meeting with Jessica, where they go over program expectations, skills for working with younger members and the community, and upcoming volunteer opportunities.
<strong>Questions?</strong> For more information about the Youth Volunteer program, please contact our Director of Volunteer Services <strong>Jessica Rubecindo,</strong> at <strong>jessica@smbgc.org.</strong>
<a href="javascript:HideContent('youthinfo')">
<strong>Click to hide above info.</strong>
</a>
</div>
</div>
<script type="text/javascript" language="JavaScript">// <![CDATA[
function HideContent(d) {
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
}
function ReverseDisplay(d) {
if (document.getElementById(d).style.display == "none") {
document.getElementById(d).style.display = "block";
} else {
document.getElementById(d).style.display = "none";
}
}
// ]]></script>

最佳答案

问题是上面的代码并不是它在页面中实际呈现的方式

这就是页面中的样子

[请勿将其重新格式化给渴望编辑的人!!!]

<p><script type="text/javascript" language="JavaScript">// <![CDATA[  function HideContent(d) {         document.getElementById(d).style.display = "none";      }       function ShowContent(d) {       document.getElementById(d).style.display = "block";         }       function ReverseDisplay(d) {        if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }      else { document.getElementById(d).style.display = "none"; }         }  // ]]&gt;</script></p>

它被渲染为单行。为什么这是一个问题,因为它以 JavaScript 注释开头。 // 该注释隐藏了所有函数。

段落标签不应包裹在脚本标签周围。我会转储 CData 标签,因为您没有使用 XHTML。

关于javascript:反向显示不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31594770/

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