如何定位要显示的网址;当默认为显示时阻止;无

问题描述 投票:0回答:1

我继承了一个使用jquery编码的网站,该网站使用jquery指定扩展器功能,以将网站的主要部分从默认关闭位置切换为打开状态(src扩展图像是彩色箭头)。默认情况下,使用“ display:none;”关闭这些部分,并且主要部分中嵌套有次要部分,默认情况下,这些部分的切换类似。基本结构如下。该网站上的切换工作正常-默认情况下,部分已关闭,但通过单击标题可在打开和关闭之间切换。现在,我想使用小节的主题标签(例如下面的示例中的“ mainpageurl#policy1”)为目标URL提供“ display:block;” URL。主题标签不起作用–网址只会在所有部分均关闭的情况下转到首页;不会打开目标。谁能提供一个简单的解决方案?是否可以完全不重写代码?也许这是什么时候不使用显示器的经典示例;没有?

<!-- <script src="https://code.jquery.com/jquery-1.10.2.js"></script> --> 
<script src="https://code.jquery.com/ui/1.11.0/jquery-ui.js"></script> 
<script type="text/javascript">
    $jq(function() {
        $jq(".expander").click(function(){
          $jq(this).next('div').toggle();
        });
    });

<h1 class="expander"><src-arrow-image-here /><a id="policies"> Policies</a></h1> 
 <div style="display: none;">
<h2 class="expander"><src-arrow-image-here /><a id="policy1"> Policy 1</a></h2> 
<div style="display: none;">
<p>Content - this is the first policy.</p> 
</div>
<h2 class="expander"><src-arrow-image-here /><a id="policy2"> Policy 2</a></h2>
<div style="display: none;">
<p>Content - this is another policy.</p>
</div></div>
javascript jquery display target expander
1个回答
0
投票

加载页面内容后,Javascript解决方案将解析window.location.hash和jQuery show()目标元素。

© www.soinside.com 2019 - 2024. All rights reserved.