【发布时间】:2019-02-05 14:55:08
【问题描述】:
我正在尝试创建一个链接列表,当点击时更新 div 中的内容。
查看下面的代码,我希望在单击链接时使用相关 div 的内容填充 id container 的 div。
<a class="glyphicon glyphicon-cutlery" onclick="fixScroll('food');"></a>
<a class="glyphicon glyphicon-cutlery" onclick="fixScroll('water');"></a>
<div id="food" style="height:20px;">Clicking Food Link Shows this in Div</div>
<div id="water" style="height:20px;">Clicking Water Link Shows this in Div</div>
<div id="container" style="width:100%; height:150px;">This Div box is Empty till you click one the links, then its Populated by the correct stuff</div>
我希望这是足够的信息。我基本上是想在单击链接时使隐藏 div 的内容(food 和water)显示在container div 中。
【问题讨论】:
标签: javascript html css onclick