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

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

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -