jquery - get part of path?
问题 I have a url that looks like this : http://mysite.com/1/2/Simpson and I want to create a variable that contains just Simpson... Not sure how to do it here... I have: var myvar = window.location.pathname and have tried something using substring, but can't seem to get it to work? 回答1: this may work, but you might as well use the string window.location.href, not the object window.location (which contains many different objects within it): var dirs = window.location.href.split( '/' ); however,