当前位置:网站首页>Object in ES6 Use of entries()

Object in ES6 Use of entries()

2022-06-13 08:47:00 fengyehongWorld

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ES6 in Object.entries() Use </title>
</head>
<body>
     Input box 1<input id="ipt1" type="text" >
    <br>
     Input box 2<input id="ipt2" type="text" >
    <br>
     Input box 3<input id="ipt3" type="text" >
</body>
<script src="./jquery.min.js"></script>
<script> /*  Specific use scenarios  1.  When initializing in the input box of the page , A fixed value is required  2.  After the search screen input conditions , Jump to the input page with the search conditions , After the input page completes the input and saves, it will take the search jump to jump back to the search screen  */ const valueObj = {
       ipt1: 'ipt1 Value ', ipt2: 'ipt2 Value ', ipt3: 'ipt3 Value ', } //  As soon as you enter the page, assign the prepared data to the input box elements in the page  $(function() {
       for (const [id, value] of Object.entries(valueObj)) {
       console.log(id, value); /* ipt1 ipt1 Value  ipt2 ipt2 Value  ipt3 ipt3 Value  */ console.log("----------"); $(`#${
        id}`).val(value); } }); </script>
</html>
原网站

版权声明
本文为[fengyehongWorld]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270537517343.html