javascript - Hash link disables relative link in HTML -
i'm building webapp one-page webapp link part of app this:
<a href="#internet"></a>
this possible because used javascript contains animations , different stuff, problem somehow, method disables possibility link this:
<a href="internet/index.html"></a>
how can have both links, without disabling hash links?
edit: honest dont know part of js causing behaviour because took template, here js:
i believe have code this
$('a').on('click', function(e) { e.preventdefault(); });
you need have if
if ($(this).attr('href').indexof('#') == 0) { e.preventdefault(); }
or better change selector to:
$("a[href^=#]").on('click', function(e) { e.preventdefault(); // animation here. });
this code apply anchor elements have href starting #
------- update --------
you added minified js :). if don't have problem in code, can fix hack this:
$('a:not([href^=#])').on('click', function(e) { window.location.href = $(this).attr('href'); });
but should find issue, not fix :)
Comments
Post a Comment