日期:2014-05-16  浏览次数:20289 次

获取URL参数
<div id="fy" style="margin-left:250px;margin-top:20px">
7 条记录 1/2 页
<a href="/bang/index.php/user/record/time/20131225/p/2.html">下一页</a>
<span class="current">1</span>
<a href="/bang/index.php/user/record/time/20131225/p/2.html">2</a>
</div>
请问如何用JS或JQ取到time和p的值

------解决方案--------------------
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="../lib/jquery/jquery-1.9.1.js"></script>
</head>
<body>
<div id="fy" style="margin-left:250px;margin-top:20px">
7 条记录 1/2 页
<a href="/bang/index.php/user/record/time/20131225/p/2.html">下一页</a>
<span class="current">1</span>
<a href="/bang/index.php/user/record/time/20131225/p/2.html">2</a>
<a href="/bang/index.php/user/record/ti/20131225/pv/2.html">2</a>
</div>
<script type="text/javascript">
var $a = $('a');
var $a_time = $.map($a,function(k){
var pos,str;
var h = k.href;
if((pos = h.indexOf('time'))!=-1){
str = h.substr(pos+5,8);
return str;
}
});
var $a_p = $.map($a,function(k){
var pos,str;
var h = k.href;
if((pos = h.indexOf('/p/'))!=-1){
str = h.substr(pos+3);
return str;
}
});




</script>
</body>
</html>