jquery - Find the anchor element where the value is equal to the hash in the URL -
how find anchor element name=
value equal hash in url, add open
class next div element?
if(window.location.hash) { var hash = window.location.hash.substring(1); //puts hash in variable, , removes # character console.log(hash); // find anchor element value equal has in url, add '.open' class next div element. $("a[name=$hash]").addclass('open'); //wrong syntax! how write this? }
$(function() { if (location.hash === "#hash") { //logic $("#divid").addclass('open'); } });
Comments
Post a Comment