Is there any specific way for click event handlers for hash-change pages? For example, suppose I have a page abc.com. Clicking on a specific tab gives us abc.com#/tab1, a hashed page. On the hashed page, I want to add click event on, say, Save button.
My implementation assumes that the elements are all child nodes of body and hence using event-delegation. However, the same does not work as desired.
window.addEventListener("hashchange", function () {
console.log(window.location.hash);
$( "body" ).on( "click", "button", function( event ) {
if (window.location.hash === "#/tab1")
console.log("testing success");
});
});