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

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -