当页数比较多的时候我们需要加一个input框来跳转到某一分页中,比如这个框 id="tiaozhuan",接下来我们用JS实现跳转
//分页跳转 $("#tiaozhuan").bind("blur",function(){ var p = $(this).val(); var href = location.href; if(/p=\d+/.test(href)){ href = href.replace(/p=\d+/,"p="+p); }else if(href.indexOf(‘?‘)==-1){ href = href+"?p="+p }else{ href = href+"&p="+p } location.href = href; }); //绑定回车事件 $("#tiaozhuan").bind("keydown",function(event){ var e = event || window.event || arguments.callee.caller.arguments[0]; if(e && e.keyCode==13){ $("#tiaozhuan").trigger(‘blur‘); } });
js input分页跳转
时间: 2024-10-15 02:41:22