【发布时间】:2017-05-02 15:00:53
【问题描述】:
这是我的代码的 sn-p:
<div id='content'>
<div id='map'></div>
<iframe name="content-wrapper"></iframe>
</div>
<div class="sidebar">
<div class="container">
<h2>Bayanihan</h2><br>
<a href="#" target="content-wrapper">Map</a> <a onclick= "hide()" href="forum.html" target="content-wrapper">Forum</a> <a href="insight.html" target="content-wrapper">Insight</a>
<hr>
<script>
function hide() {
$(map).hide();
}
</script>
基本上,我的网站是一个带有侧边栏的地图。在侧边栏中,有三个链接:map, forum, insight。所以我想要发生的是,如果我点击论坛,地图背景将消失并被forum.html 取代,洞察力也是如此。正如您在 sn-p 中看到的那样,我首先在论坛上尝试它。 html 但它不起作用。
【问题讨论】:
-
$(map)- 地图定义是什么? -
稍微研究一下 jQuery 选择器。如果您尝试隐藏 ID 为
map的元素,则需要为其添加前缀#。此外,由于map不是变量,因此您需要用引号将其封装起来。应该是$("#map").hide();
标签: javascript jquery html css iframe