Home  >  Article  >  Web Front-end  >  Detailed explanation of the problem of page jump and passing parameters in HTML

Detailed explanation of the problem of page jump and passing parameters in HTML

王林
王林forward
2020-03-19 18:42:142788browse

Detailed explanation of the problem of page jump and passing parameters in HTML

The effect is as shown below:

a page

Detailed explanation of the problem of page jump and passing parameters in HTML

##After clicking the jump button

Detailed explanation of the problem of page jump and passing parameters in HTML

The corresponding value can be obtained on page b.

Recommended tutorial:

html tutorial

The code is as follows:

a page:

<!DOCTYPE html>
<html>
<head>
    <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>

The b page to be jumped to:

<!DOCTYPE html>
<html>
<head>
    <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>

Recommended related video tutorials:

html video tutorial

The above is the detailed content of Detailed explanation of the problem of page jump and passing parameters in HTML. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete