Home >Web Front-end >HTML Tutorial >How to pass parameters when page jump in html

How to pass parameters when page jump in html

php中世界最好的语言
php中世界最好的语言Original
2018-01-18 09:25:455326browse


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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn