Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link to div inside div within same HTML

I am currently using Bootstrap Timeline (example here). Since this will be a long timeline I want at the top of it to have some symbols (each with a date and a unique ID), which will represent certain event. When clicking a certain symbol I want to be redirect to the correspondent event on the timeline.

Nevertheless, at the moment, when I click the symbol I am redirected to the top of the div 'container' which contains the timeline and not to the specific <li>

Example: LINK:

<ol class="timeline">
   <li class="timeline__step done">
        <a href="#type1" id="type1"></a>
    </li>

</ol>

TO:

<div class="container">
     <ul class="timeline2">
        <li id = "type1" onclick = "window.location.hash = 'type1';">
        </li>
     <ul>
<div>`
like image 594
DMBorges Avatar asked May 28 '26 10:05

DMBorges


1 Answers

Remove id from the link and remove the onclick from the timeline item. The hashtag in href should jump to the id set in the timeline item.

<ol class="timeline">
   <li class="timeline__step done">
        <a href="#type1"></a>
    </li>
</ol>

<div class="container">
     <ul class="timeline2">
        <li id="type1">
        </li>
     <ul>
<div>
like image 162
iDev247 Avatar answered Jun 01 '26 01:06

iDev247



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!