I need assistance with a webpage where items are listed using unique ids. I want the page to scroll up or down, depending on which link the user clicks, to find the element with the id specified in the address bar as foo=or2
. Additionally, I would like the CSS focus style to be applied to that particular element.
JavaScript code sample:
$(document).ready(function (){
// Need help extracting the id from the URL
$('div').focus();
// Unsure of what needs to be added to make it functional
});
Sample URL for focusing on a 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>