javascript - What is stopping my JS from getting my URL Hash? -


so trying add class on element, after hyperlinking separate page. have link on page1 set this:

<a href="https://jsfiddle.net/mv7nneu4/2#redbox">go redbox</a>

and on page2 running function:

$(function() {     var id = window.location.hash;     $(id).addclass('expanded'); }); 

this div should affecting:

<div id="redbox" class="red">   hajkldjfs </div> 

which, should grabbing hash, adding class expanded element. class never gets appended , console has no errors.

here 2 js fiddle links created simulate this:

page1

page2

appreciate help!

your selector wrong. change

$('#' + id).addclass('expanded'); 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -