#2
apull2022-07-19 11:56
|
url地址:http://localhost:8014/products.asp?page=1&sortID=
页面代码:
程序代码:
<i id="pronumber">
<%for i = 1 to n%>
<a href="<%=filename%>?page=<%=i%>&<%=url%>"><span id="spanhover"><%=i%></span></a>
<%next%>
</i>
<%for i = 1 to n%>
<a href="<%=filename%>?page=<%=i%>&<%=url%>"><span id="spanhover"><%=i%></span></a>
<%next%>
</i>
js代码:
程序代码:
<script type="text/javascript">
function getQueryVariable(variable){
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){
return pair[1];
}
}
return(false);
}
var page = getQueryVariable("page"); //提取url链接page后面的数值,赋予page
var spanhover = document.getElementById("spanhover");
var spans = document.querySelectorAll("#pronumber span");
function myFun(){
for( var j=0 ; j<spans.length ; j++ ){
var spanid = spans[j].innerText;
if( spanid == page ){
spanhover.style.background = "red";
spanhover.style.color = "#fff";
};
};
};
myFun();
function getQueryVariable(variable){
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){
return pair[1];
}
}
return(false);
}
var page = getQueryVariable("page"); //提取url链接page后面的数值,赋予page
var spanhover = document.getElementById("spanhover");
var spans = document.querySelectorAll("#pronumber span");
function myFun(){
for( var j=0 ; j<spans.length ; j++ ){
var spanid = spans[j].innerText;
if( spanid == page ){
spanhover.style.background = "red";
spanhover.style.color = "#fff";
};
};
};
myFun();
现在的问题是点击第2页时,样式还是作用在第1个。
这里要怎么修改,求告知。真诚感谢!!!