Get hash value from url

前端 未结 5 1382
执念已碎
执念已碎 2020-12-24 07:06

I\'m trying to get the hash value after a link was clicked. Any ideas?

e.g.

The Link

index.html#needThis

This is my result:

5条回答
  •  北海茫月
    2020-12-24 07:52

    Just use var hash = window.location.hash.

    It returns everything after #

    Or if you've got a variable which contains an url:

    $(this).attr('href').substring($(this).attr('href').indexOf('#'))
    

提交回复
热议问题