Get css id from url

前端 未结 1 434
说谎
说谎 2021-01-28 21:40

It\'s probably a silly question but is there a way to get the css id selected from the url? For example in a url like this:

www.website.com#adiv
<
相关标签:
1条回答
  • 2021-01-28 22:37

    That would be window.location.hash

    var hash = window.location.hash;
    $(hash).addClass(...);
    

    Or directly

    $(window.location.hash).addClass(...);
    
    0 讨论(0)
提交回复
热议问题