使用jQuery获取浏览器URL

Get browser URL with jQuery

本文关键字:URL 浏览器 获取 jQuery 使用      更新时间:2023-09-26

我有这个代码

var pathname = window.location.pathname;

即采用当前浏览器url

如何将路径名粘贴到像p标记一样的html元素中?

使用此:

$('p.class').html(location.pathname);

如果你想得到完整的网址:

$('p.class').html(location.href);