Click Button with URL Hash String

Autosort data on a page from a hash URL using the following snippet and related HTML.

if(window.location.hash) {
     jQuery('a.' + window.location.hash.substr(1)).click();
}
foreach($terms as $term) { ?>
     <li class="section_toggle">
          <a href="#" class="<?php echo $term->slug; ?>"><?php echo $term->name; ?></a>
     </li>
<?php }

Source.

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.