我有以下过于复杂的遗留代码,我必须修复。我的问题是在minus_sign / plus_sign切换的两个实例下使用jQuery代码片段。如果显示sub_items,我想要的只是改变的那个:block。如果有人可以帮助我,我会非常感激。希望这是有道理的。
HTML
<li data-id="02" class="nav__module nav__chapter-02">
<div class="nav__module-heading" role="heading" aria-level="2">
<a id="headLnk_02" class="trigger_02 chapter_link" href="../content/m01/m01_c02_p00.html">
<span class="nav__module-heading-number">Module 2</span>
<span class="nav__module-heading-title menu_ch02">Dashboards</span>
</a>
<a tabindex="-1" aria-hidden="true" class="expand_collapse" href="#">
<span class="fa fa-chevron-down"></span>
<span class="chapter_expand">Expand</span>
</a>
</div>
<ul aria-labelledby="headLnk_02" class="nav__items">
<li class="sub_p01">
<span aria-hidden="true">
<span class="exp plus_sign plus01"><span class="offThePage">plus/minus</span></span>
<span class="exp minus_sign minus01"><span class="offThePage">plus/minus</span></span>
</span>
<a id="subLnk_01" class="parent_link menu_p01" href="../content/m01/m01_c02_p01.html">Publishing dashboard</a>
<ul aria-labelledby="subLnk_01" class="sub_items">
<li><a href="../content/m01/m01_c02_p01-a.html" class="menu_p01a" >Publishing process</a></li>
<li><a href="../content/m01/m01_c02_p01-b.html" class="menu_p01b" >When to use the<br/>Publishing dashboard</a></li>
<li><a href="../content/m01/m01_c02_p01-c.html" class="menu_p01c" > Approving multiple items</a></li>
</ul>
</li>
<li class="sub_p04">
<span aria-hidden="true">
<span class="exp plus_sign plus04"><span class="offThePage">plus/minus</span></span>
<span class="exp minus_sign minus04"><span class="offThePage">plus/minus</span></span>
</span>
<a id="subLnk_04" class="parent_link menu_p04" href="../content/m01/m01_c02_p04.html">Control panel</a>
<ul aria-labelledby="subLnk_04" class="sub_items">
<li><a href="../content/m01/m01_c02_p04-a.html" class="menu_p04a">Site configuration</a></li>
</ul>
</li>
</ul>
</li>
的jQuery
$( ".sub_items:hidden").attr( "aria-hidden", "true" );
$( ".sub_items:visible").attr( "aria-hidden", "false" );
if($('.sub_items').is(':visible'))
{
$('.minus_sign').show();
$('.plus_sign').hide();
}