我被这个问题困住了:我想根据用户的选择显示特定的 div。div 是嵌套的,最好以某个 id 为目标。
这是我想在屏幕上可视化的算法/站点地图:
这是我的初稿:
HTML:
<div class="buttons">
<button class="showButton" target="1">Button 1</button>
<button class="showButton" target="6">Button 2</button>
<button class="showButton" target="3">Button 3</button>
</div>
<div id="div1" class="targetDiv">Content of div 1.<br />
<button class="showButton" target="4">open 4</button>
<button class="showButton" target="5">open 5</button>
<div id="div4" class="targetDiv">This is div 4.</div>
<div id="div5" class="targetDiv">This is div 5.</div>
</div>
<div id="div2" class="targetDiv">Content of div 2.<br/>
<button class="showButton" target="9">open 9</button>
</div>
<div id="div3" class="targetDiv">Content of div 3.<br/>
<button class="showButton" target="6">open 6</button>
<div id="div6" class="targetDiv">Content of div 6.<br />
<button …Run Code Online (Sandbox Code Playgroud)