Javascript 使用jQuery获取浏览器URL
我有这个密码Javascript 使用jQuery获取浏览器URL,javascript,jquery,Javascript,Jquery,我有这个密码 var pathname = window.location.pathname; 获取当前浏览器url的 如何将路径名粘贴到html元素(如p标记)中?使用以下方法: $('p.class').html(location.pathname); 如果要获取完整的URL: $('p.class').html(location.href); 使用以下命令: $('p.class').html(location.pathname); 如果要获取完整的URL: $('p.class'
var pathname = window.location.pathname;
获取当前浏览器url的
如何将路径名粘贴到html元素(如p标记)中?使用以下方法:
$('p.class').html(location.pathname);
如果要获取完整的URL:
$('p.class').html(location.href);
使用以下命令:
$('p.class').html(location.pathname);
如果要获取完整的URL:
$('p.class').html(location.href);
凉的你尝试了什么,发生了什么?酷。你尝试了什么,发生了什么?仅供参考——如果你想获取URL而不是路径,可以使用
locaiton.href
。没错,但是如果你只想获取路径名(对于本页面,它应该是/questions/9948212/jquery获取浏览器URL并插入html元素
),您可以使用这个fyi——如果想要获取URL而不是路径,可以使用locaiton.href
。没错,但是如果您只想要路径名(对于这个页面,它应该是/questions/9948212/jquery get browser URL并插入html元素
),您可以使用这个