javascript - execute/trigger a script depending on #anchor in url? -


i have central page example.com/info/requirements contains requirements run different applications. default div shows requirements flagship application shown, , users can click buttons switch on/off different div.

<a id="main-app"></a> <div id="req-container-main" class="invisible">     [requirements listed here] </div> <a id="app2"></a> <div id="req-container-app2" class="invisible">     [requirements listed here] </div> <a id="app2"></a> <div id="req-container-app3" class="invisible">     [requirements listed here] </div> <a id="app4"></a> <div id="req-container-app4" class="invisible">     [requirements listed here] </div> 

i have landing page each of apps. contain link requirements page including anchor, example.com/info/requirements#app3

now i'm looking way - using js/jquery - checks existence of #anchor when page accessed , can trigger openreqdiv('#app3'); function have in place.

can please point me in right direction when, , how check anchor , trigger script? thank you!

this thing called routing. approach rather simple, no worries. do:

var hash = window.location.hash; switch(hash){     case '#app2':         $("#app2").removeclass('invisible');         break; } 

however, want detect changes hash. use plugin such https://github.com/asual/jquery-address. option use framework of kind(angular, ember...)


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -