Home > Web Front-end > HTML Tutorial > Share the example code of page jump and passing parameters in html

Share the example code of page jump and passing parameters in html

零下一度
Release: 2017-05-08 11:37:34
Original
1872 people have browsed it

This article mainly introduces the relevant information on the problem of passing parameters in html page jumps. Friends who need it can refer to it

The effect is as follows:

a page

Click the jump button and then

The corresponding value can be obtained on the b page.

The code is as follows:

a page:

<!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>
Copy after login

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>
   <p id="name"></p>
   <p id="age"></p>
</body>
</html>
Copy after login

[Related recommendations]

1. Free html online video tutorial

2. html development manual

3. php.cn original html5 video Tutorial

The above is the detailed content of Share the example code of page jump and passing parameters in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template