從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

相關文章
相關標籤/搜索