Yobd Digital Yobd Digital - 7 months ago 28
Javascript Question

Javascript not adding id in address bar

For some reason this javascript will not add the id of the clicked element into the address bar. It will do everything else correctly.

here is the jsfiddle:
http://jsfiddle.net/4x7La64s/

so for example if I click on

#introduction
I want it to put the id in the address bar like so:
example.com/page.php/#introduction

Answer

Remove the prevent default function:

e.preventDefault();