Home >Web Front-end >HTML Tutorial >How to pass parameters when page jump in html
This time I will show you how to pass parameters when page jumps in html, and what are the precautions of how to pass parameters when page jumps in html, here are Let’s take a look at practical cases.
a page
After clicking the jump button
you can get the corresponding value on page b.
<!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 page to be jumped to:
<!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>
I believe you have mastered the method after reading these cases. For more exciting information, please pay attention to the php Chinese websiteOtherrelated articles !
Related reading:
How to use the img tag of HTML images
How to use HTML to implement the scrolling barrage function
What is the difference between name, id and class in HTML
The above is the detailed content of How to pass parameters when page jump in html. For more information, please follow other related articles on the PHP Chinese website!