I have a page that content are listed using a unique id, and i want whenever user click on links to view any of these item it will scroll down or up to locate the element with the id in the address bar foo=or2
and at the same time it will apply css focus style to that element.
I have tried to do it by this but didn't work for me can anyone help with this?
Jquery code
$(document).ready(function (){
// I don't know how to get the id from url
$('div').focus();
// I also don't know what else to do to make it work
});
Here is my example url to focus on div element
http://www.example.com?see=orang$foo=or2
HTML EXAMPLE
div:focus {
background: red;
}
<div id="or1">Orange</div>
<div id="or2">Mango</div>
<div id="or3">Banana</div>
<div id="or4">Pear</div>