本文摘自PHP中文网,作者小云云,侵删。
本文主要介绍了html页面跳转传递参数问题的相关资料,需要的朋友可以参考下,希望能帮助到大家。效果如下:
a页面
点击跳转按钮后
在b页面可以获取到对应的值。
代码如下:
a页面:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <!DOCTYPE html>
<html>
<head lang= "en" >
<meta charset= "UTF-8" >
<script src= "js/jquery-3.0.0.min.js" ></script>
<script src= "js/jquery.params.js" ></script>
<title>a页面</title>
<script>
$( function (){
name = $( "#name" ).text();
age = $( "#age" ).text();
$( "#btn" ).on( "click" , function (){
jump1();
});
});
function jump1(){
url = "b.html?name=" +name+ "&age=" +age;
window.location.href = url;
}
</script>
</head>
<body>
<p id= "name" >tony</p>
<p id= "age" >23</p>
<button id= "btn" >跳转</button>
</body>
</html>
|
将要跳转到的b页面:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <!DOCTYPE html>
<html>
<head lang= "en" >
<meta charset= "UTF-8" >
<script src= "js/jquery-3.0.0.min.js" ></script>
<script src= "js/jquery.params.js" ></script>
<title>b页面</title>
<script>
$( function (){
getData1();
});
function getData1(){
var name = $.query.get( "name" );
var age = $.query.get( "age" );
$( "#name" ).text(name);
$( "#age" ).text(age);
}
</script>
</head>
<body>
<p id= "name" ></p>
<p id= "age" ></p>
</body>
</html>
|
大家学会了吗?赶紧动手自己尝试一下吧。
相关推荐:
比较总结mui页面跳转方式之间的差异
php 不使用js实现页面跳转怎么实现
关于html页面跳转的7篇文章推荐
以上就是关于html页面跳转传递参数问题解答的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
Html 本地存储
Html s标签怎么用
canvas实现压缩图片的代码示例
Html cite标签的用法你知道吗?Html cite属性的具体用法介绍
可替换元素是什么?(附示例)
Html超链接怎么设置
css+Html实现模拟百度首页(附代码)
Html5编程需要什么软件?
jquery实现带弹窗和次数的转盘抽奖(代码)
Html input是什么
更多相关阅读请进入《Html》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » 关于html页面跳转传递参数问题解答