js控制页面带参跳转:
方法1:html中href没有指向跳转页面 html: <input class="weui-input phone-input" id="edit-phone-input" type="number" oninput="if(value.length>11) value=value.slice(0,11)" pattern="/^13[0-9]{9}$|(^14)[5,7]\d{8}$|15[012356789]\d{8}$|18[0-9]{9}$|17[0-9]{9}$/" placeholder="请输入您的手机号"/> <input class="weui-input code-input" type="number" placeholder="输入验证码"> <a href="javascript:;" class="weui_btn weui_btn_primary btn-gradient-confirm" id="confirm-edit-phone">确定修改</a> Js: var value1=$(‘#edit-phone-input‘).val(); var value2=$(‘.code-input‘).val(); alert(value1); alert(value2); var link ="personal-message.html" + ‘?value1=‘+value1 + ‘&value2=‘+value2; window.location.href=link; //这样就可以传过去了
方法2:html的href中指向了跳转页面:html: <input class="weui-input phone-input" id="edit-phone-input" type="number" oninput="if(value.length>11) value=value.slice(0,11)" pattern="/^13[0-9]{9}$|(^14)[5,7]\d{8}$|15[012356789]\d{8}$|18[0-9]{9}$|17[0-9]{9}$/" placeholder="请输入您的手机号"/> <input class="weui-input code-input" type="number" placeholder="输入验证码"> <a href="personal-message.html" class="weui_btn weui_btn_primary btn-gradient-confirm" id="confirm-edit-phone">确定修改</a> Js: var value1=$(‘#edit-phone-input‘).val(); var value2=$(‘.code-input‘).val(); this.href = this.href + ‘?value1=‘+value1 + ‘&value2=‘+value2; //这种方式可以在下一个页面中获取前一个页面传在url中的参数
时间: 2024-10-07 21:47:17