基于URL的DIV内容隐藏/显示

时间:2016-05-27 05:34:02

标签: javascript html css pentaho

在html页面中,我有一个div-reportControlPanel,如下所示。我已将另一个div-reportControlPanel1包含为不同的ID。

<div id="reportControlPanel" class="pentaho-rounded-panel-bottom-lr pentaho-shadow">
<div id="promptPanel" class="pentaho-rounded-panel-bottom-lr"></div>
</div>

<div id="reportControlPanel1" class="pentaho-rounded-panel-bottom-lr pentaho-shadow">
<div id="promptPanel" class="pentaho-rounded-panel-bottom-lr"></div>
 </div>

此处显示/隐藏基于div's触发的url

    if(prptName == "css.prpt")
{
alert("if");
document.getElementById("reportControlPanel").style.display = 'none';
document.getElementById("reportControlPanel1").style.display = 'block';
}

但由于在两个不同的div内使用相同的子Div- promptPanel ,我的内容无法正确加载。 promptPanel pentaho system使用了div div。我正在尝试另一个css来修改prpt的{​​{1}}。

感谢。

1 个答案:

答案 0 :(得分:0)

重申Moishe已经对你说过的话:wxthread是唯一的。您目前有两个id个ID,这意味着第二个可能永远不会被调用。现在,您可以使用javascript,但是对于您的代码看起来很少的知识,您可以使用简单的哈希URL +一些基本的CSS。

promptPanel
$(document).ready(function() {
  $('a').click(function() {
    $('#url').html($(this).prop('href'));
  });
});
div.pentaho-rounded-panel-bottom-lr {
  display: none;
}
div.pentaho-rounded-panel-bottom-lr .pentaho-rounded-panel-bottom-lr {
  display: block;
}
:target {
  display: block !important;
}