如何从下拉菜单中将标签锚定到特定的 div

问题描述 投票:0回答:0

我有一个页面,我在其中使用下拉选择器,并希望锚定链接我的 URL 中的部分,但是当我在我的 URL 末尾使用 #show1 时,指定的下拉列表不显示。

对我做错了什么有什么看法吗?

提前谢谢你!

当前 HTML 片段:

<center><select id="myselection">
    <option>Select Your Model</option>
    <option value="1">Section 1</option>
    <option value="2">Section 2</option>
    <option value="3">Section 3</option>
    </select>


<div id="show1" class="myDiv">
<center>

  <div class="responsive-two-column-grid">

<div><img src="#"></div>
<div><h3 style="margin-top: 70px!important;">Header 1</h3><p>copy goes here</p></div>
</div>

<div id="show2" class="myDiv">
<center>

  <div class="responsive-two-column-grid">

<div><img src="#"></div>
<div><h3 style="margin-top: 70px!important;">Header 1</h3><p>copy goes here</p></div>
</div>

<div id="show3" class="myDiv">
<center>

  <div class="responsive-two-column-grid">

<div><img src="#"></div>
<div><h3 style="margin-top: 70px!important;">Header 1</h3><p>copy goes here</p></div>
</div>

I would like the specified div to show when I specify the id at the end of the URL. ie - using *#show1* at the end of my URL would bring the person to this part: 

<div id="show1" class="myDiv">
<center>

  <div class="responsive-two-column-grid">

<div><img src="#"></div>
<div><h3 style="margin-top: 70px!important;">Header 1</h3><p>copy goes here</p></div>
</div>

javascript html drop-down-menu anchor
© www.soinside.com 2019 - 2024. All rights reserved.