简体   繁体   中英

how to open a link on click of an element in navbar in html

I'm trying to add the link to the first element of the dropdown that is "MORE" so that I could go to another page but I'm not able to do that. I have tried it many times but not able to do it.

The Code:

<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" style="font-family: 'Roboto', sans-serif; font-size: 15px; color: white;">More<b class="caret"></b></a>
  <ul class="dropdown-menu">
    <li><a href="#">Python</a></li>
    <li><a href="#">AngularJS Framework</a></li>
    <li><a href="#">.NET Framework Development</a></li>
    <li><a href="#">Swift App Development</a>   </li>
    <li class="divider"></li>
    <li><a href="Blogs/Java/Java-Page.aspx">Java App Development</a></li>
  </ul>
</li>

If you need the submenu to display onclick, consider using jQuery. Or if you want the menu to appear on hover, remove the jQuery in this fiddle and uncomment the piece of CSS that will handle that. - https://jsfiddle.net/awwys0z6/1/ . Otherwise, you may have to restructure your menu like this - Show hide divs on click in HTML and CSS without jQuery

$('.dropdown').click(function() {
    $('.show').toggle('.show');
});

Using jQuery

$('element').on('click', function(){
//do whatever u want
});

Using javascript

<nav>
<div onclick="linkFn()">click here</div>
</nav>

function linkFn() {
//do whatever u want
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM