Get current URL with jQuery?

后端 未结 30 2282
你的背包
你的背包 2020-11-22 02:44

I am using jQuery. How do I get the path of the current URL and assign it to a variable?

Example URL:

http://localhost/menuname.de?foo=bar&nu         


        
30条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 03:10

    If you need the hash parameters present in the URL, window.location.href may be a better choice.

    window.location.pathname
    => /search
    
    window.location.href 
     => www.website.com/search#race_type=1
    

提交回复
热议问题