效果如下:
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 > < div id = "name" >tony</ div > < div id = "age" >23</ div > < 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 > < div id = "name" ></ div > < div id = "age" ></ div > </ body > </ html > |
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容