How to capture button event in Chrome, Firefox and IE
2 answers
Update In the next function, when you click on the links, you will see that the event is fired .... now after clicking on any link, click the button where you will fire the event.
$(window).bind( "hashchange", function(e) {
alert()
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://github.com/cowboy/jquery-bbq/raw/v1.2.1/jquery.ba-bbq.min.js"></script>
<nav id="siteNav">
<ul>
<li class="nav1"><a href="#landing" title="Home">Home</a>
<li class="nav2"><a href="#products" title="Products">Products</a>
<li class="nav3"><a href="#about-us" title="About Us">About Us</a>
<li class="nav4"><a href="#sign-up" title="Sign Up">Sign Up</a>
<li class="nav5"><a href="" title="Videos">Videos</a>
</ul>
</nav>
Use event hashchange
:
window.addEventListener("hashchange", function(e) {
// ...
})
+3
source to share