【发布时间】:2011-06-07 02:38:27
【问题描述】:
我有以下网址:
http://www.mysite.co.uk/?location=mylocation1
我需要从URL中获取location的值到一个变量中,然后在jQuery代码中使用:
var thequerystring = "getthequerystringhere"
$('html,body').animate({scrollTop: $("div#" + thequerystring).offset().top}, 500);
如何使用 JavaScript 或 jQuery 获取该值?
【问题讨论】:
-
var locationValue = (new URL(location.href)).searchParams.get('location')
标签: javascript jquery query-string