TheDarkCode
TheDarkCode

Reputation: 411

Toggle class to specific element depends on hash from URL

How toggle class to specific html element if the hash e.g) equal #area & the id="Hafr"

i need to toggle

class="opened"

to this element

<div id="hafr"></div>

if the hash from the url = #area

please look for my submenu in jsfiddle! http://jsfiddle.net/samehsubscription/8u5qy/

Upvotes: 1

Views: 611

Answers (1)

TheDarkCode
TheDarkCode

Reputation: 411

if (window.location.hash == '#area') $('#hafr').addClass('opened');

Thanx @abhitalks

Upvotes: 1

Related Questions