Let's say I have the html as below:
<div class=".blog-item-holder">
<div id="AAAA"><div class="inner">AAAA</div></div>
<div id="BBBB"><div class="inner">BBBB</div></div>
<div id="CCCC"><div class="inner">CCCC</div></div>
<div id="DDDD"><div class="inner">DDDD</div></div>
</div>
So reach of my url will be reset like this:
example.com/page/#AAAA
and
example.com/page/#BBBB
and
example.com/page/#CCCC
and
example.com/page/#DDDD
All I want is when people go to the page (for example: example.com/page/#BBBB
) then the div#BBBB .inner
will have a black back-ground, and same treatment for the url has has for CCCC, DDDD etc.
This is what I got so far on js:
if(window.location.hash) {
var hash = window.location.hash.substring(1),
boxes = [];
$('.blog-item-holder > div').each(function(){
if ($(this).attr('id') == hash) {
$(this).children('div').css("background-color:#000000;");
}
});
}
But somehow it doesn't seem to be working.