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

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

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -