0
我试图显示/隐藏某些div后,用户在谷歌API图上的侧边栏点击一个div。的div被设置为:根据用户点击显示/隐藏div?
<div id="Map">
<div id="sidebarContainer">
<div id="sidebar">
<div class="level1">
<div class="level 2 primary [name of distributor]" id="[name of distributor]">
[text data about the distributor in cased in some divs]
</div>
</div>
</div>
</div>
</div>
然后对子公司:
<div class="level1">
<div class="level 2 subsidiary [name of distributor]" id="[name of distributor]" style="display:none">
我的目标是当上主DIV用户点击,它会显示所有子公司的div。主要和子公司在结构上处于“相同”水平,只是没有取决于分销商的类别。我试过这个javascript:
google.maps.event.addListener(
document.getElementsByClassName('level 2 primary ' + listingInfo.PARTY_NAME),
'click',
function() {
console.log(listingInfo.PARTY_NAME + ' INSIDE THE CLICKY CLICKY');
document.getElementsByClassName(listingInfo.PARTY_NAME)
.style.display = 'inline-block';
}
);
其中listingInfo.PARTY_NAME = [name of the distributor]
。
我也试过在1级div上做听众,但那似乎不起作用。我一直无法让我的日志消息出现,但我无法弄清楚我做错了什么。任何帮助表示赞赏!
我建议JQuery的这个http://api.jquery.com/hide/。有什么理由不能使用JQuery吗? – Reinard
我不这么认为。生病调查。但是我认为即使目前没有显示,显示/隐藏仍然需要布局空间吗? – Blaris
它不应该。至少我从未体验过与Bootstrap一起使用时占用空间的问题。 – Reinard