超链接: http://xxxxxxx.html?id=10
$(function(){
var idPre = window.location.href.split("?")[1];
var id = idPre.split("=")[1];
解释说明:
window.location.href 获取整个链接
window.location.href.split(“?”)[ 1 ] ; 从?切开,[1]的意思是取右边,即取出了 id = 10
再对=分割,取右边[1],就得到了 数字10
本文介绍了如何使用JavaScript从URL中获取超链接的参数值。通过`window.location.href`获取整个链接,然后利用`split()`方法解析参数,最终得到参数值。
1497

被折叠的 条评论
为什么被折叠?



