• 获取多个input输入的值,放在多个指定的div上


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    </head>
    <body>
    <!-- <input type="text" oninput="yz(this)"> -->
    <input type="text" name="demo" id="ceshi1">
    <input type="text" name="demo" id="ceshi2">
    <input type="text" name="demo" id="ceshi3">
    <span id="ceshi1-s"></span>
    <span id="ceshi2-s"></span>
    <span id="ceshi3-s"></span>
    <button id="save">点击保存</button>
    <script src="jquery-1.8.3.min.js"></script>
    <script>
    var globalData = {}
    $("#save").click(function(){
    $("input[name='demo']").each(function(){
    globalData[$(this).attr("id")] = $(this).val() || "";
    });
    for(v in globalData){
    $("#"+v+"-s").text(globalData[v])
    }
    console.log(globalData)
    })
    </script>
    </body>
    </html>
  • 相关阅读:
    调试
    node笔记汇总
    移动端布局
    css 易错点总结
    Angular笔记
    CANVAS笔记
    http笔记汇总
    各种环境搭建 软件安装等等 参考网址收录
    js中同步异步,任务队列
    node.js之fs模块
  • 原文地址:https://www.cnblogs.com/wssdx/p/8252408.html
Copyright © 2020-2023  润新知