从url(地址栏)获取参数:Jquery中getUrlParam()方法的使用

我想要获取以下id spa

以下代码(传参要加问好!!)code

function getUrlParam(id) { var regExp = new RegExp('([?]|&)' + id+ '=([^&]*)(&|$)'); var result = window.location.href.match(regExp); if (result) { return decodeURIComponent(result[2]); } else { return null; } } var id = getUrlParam("id"); alert(id);

效果:blog

相关文章
相关标签/搜索