zoukankan      html  css  js  c++  java
  • jquery-ajax中的serialize()

    serialize()方法是将表单文本序列化,生成 URL 编码文本字符串

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <script src="jquery-3.4.1.js"></script>
        <script>
        $(document).ready(function(){
            $('button').click(function(){
                $('#div2').text($('form').serialize());
            })
        })
        </script>
        <style>
            #div2{
                font-size: 20px;
                color: red;
            }
        </style>
    </head>
    <body>
        <form action="">
           姓名:<input type="text" name='name' value="WuKong"><br><br>
           年龄:<input type="text" name= 'age' value='666'>
        </form><br><br>
        <button>点一下</button>
        <div id="div2"></div>
    </body>
    </html>

      页面内容:

    点击按钮之后

    如果把文本内容换成汉字

       <form action="">
           姓名:<input type="text" name='name' value="悟空"><br><br>
           年龄:<input type="text" name= 'age' value='666'>
        </form><br><br>

      刷新页面,点击按钮

      

    ╰︶﹉⋛⋋⊱⋋๑๑⋌⊰⋌⋚﹉︶╯
  • 相关阅读:
    设计模式开始--工厂模式
    设计模式开始--UML类之间关系表示
    设计模式开始1--不明觉厉
    Gas Station
    Validate Binary Search Tree
    Word Ladder
    (转)基于快速排序的TOPK算法
    Number of 1 Bits
    Word Search
    Rotate Array
  • 原文地址:https://www.cnblogs.com/zhangcheng001/p/11147900.html
Copyright © 2011-2022 走看看