在Javascript中从href获取路径名 [英] Get pathname from href in Javascript
本文介绍了在Javascript中从href获取路径名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从锚标签href属性返回路径名的最简单方法是什么?
whats the simplest way to return the "pathname" from an anchor tags href attribute?
示例...说我有:
<a href="http://www.example.com/this/is/my/path.html">Blah</a>
我只需返回此/this/is/my/path.html部分。
I need to return only this "/this/is/my/path.html" part.
想法?我正在使用jQuery如果有帮助..
Ideas? I'm using jQuery if it helps..
谢谢!
推荐答案
我认为你可以使用路径名
I think you can use pathname
$('a')[0].pathname;
这篇关于在Javascript中从href获取路径名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文