How to copy JS variables? [A novice, please give me some advice]
P粉668901898
P粉668901898 2023-06-28 17:54:37
0
2
537

On the query page, the copy button can only copy the content of the div above. How to copy the content below? ? ? please. . . . . .


##<script>

function copyArticle(event) {


const range = document .createRange();


## range.selectNode(document.getElementById('content'));



        const selection = window.getSelection();


                    const selection = window.getSelection();

##                             const selection = window.getSelection();

selection.addRange(range);


## document.execCommand('copy');


alert("Copying [legal representative] successfully!");


## }

</script>


<div class="col-md-6 footer-grid">

<h4 class="footer-head">Unified Society Credit code: <span id="content">{$art.tyshdm}</span></h4>

                                                                                               ;p style="text-indent: -5em;margin-left: 5em">Name:<span id="content1">{$art.gsname}</span>

</li>

                                                                                                                                                                                                                                                 #</li> ##</li>

                                                                                                                                                                                                                                                                                    

</li>

</ul>

</div>

<div class="col-md-6 footer-grid">

<h4 class="footer-head"> </h4>

<ul>

<li><p style="text-indent: -5em;margin-left: 5em">Establishment date: {$art.clrq}

& lt;/li & gt;

& lt; li & gt; & lt; p style = "text-indent: -5em; margin-heft: 5EM" & gt; approval date: {$ Art.hzrq}

</li>

                                                                                                                                                                                                                                                }

</li>

                                                                                                                                                                                                                                                                                   ="content3">{$art.jycs}</span>

</li>



</ul>

</div>


111.png##

P粉668901898
P粉668901898

reply all(1)
WBOY

Shallow copy: Use `Object.assign()` or the spread operator `...` to copy an object, use `Array.from()` or the spread operator `...` to copy an array. For example:

let obj1 = { name: 'Alice', age: 20 };
let obj2 = Object.assign({}, obj1); // 浅拷贝对象
console.log(obj2); // 输出{ name: 'Alice', age: 20 }

let arr1 = [1, 2, 3];
let arr2 = [...arr1]; // 浅拷贝数组
console.log(arr2); // 输出[1, 2, 3]

-Deep copy: Use `JSON.parse()` and `JSON.stringify()` to implement deep copy. For example:

let obj1 = { name: 'Alice', age: 20 };
let obj2 = JSON.parse(JSON.stringify(obj1)); // 深拷贝对象
console.log(obj2); // 输出{ name: 'Alice', age: 20 }

let arr1 = [1, 2, [3, 4]];
let arr2 = JSON.parse(JSON.stringify(arr1)); // 深拷贝数组
console.log(arr2); // 输出[1, 2, [3, 4]]

  • reply Received, thank you very much for your help!
    P粉668901898 author 2023-06-29 20:35:51
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!