I want to make jQuery navigates directly (no animation need) to a id that I pass in a variable.
I have various marks like id="content"
, id="edit"
, id="..."
that are <h2>
titles. Doing validation with PHP I will output a variable like var NAVIGATE_TO = <?php echo $where_failed;?>
and I want to move the website to that id
position.
Like if I do domain.tld/page#edit
or #content
but with jQuery because when I load the page my PHP framework doesn't allow me to indicate the hash.
You can set location.hash
to the id
you need the browser to scroll to:
window.location.hash = '#edit';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With