jquery - How can you check for a #hash in a URL using JavaScript?

preview_player
Показать описание
#short
#javascript
#jquery
#anchor
#fragment-identifier
I have some jQuery/JavaScript code that I want to run only when there is a hash (#) anchor link in a URL. How can you check for this character using JavaScript? I need a simple catch-all test that would detect URLs like these:

Basically something along the lines of:
if (thereIsAHashInTheUrl) {
do this;
} else {
do this;
}
Рекомендации по теме
visit shbcf.ru