current position:Home>Web development front-end questions

Web development front-end questions

2022-02-03 02:39:53 CSDN Q & A

script How the code controls the specified code block , Without affecting other code areas ?




Refer to the answer 1:

To prevent variable pollution , You can expand the code to be executed with an immediate execution function , Instead of putting the code directly in script In the implementation of , Otherwise, variables will lead to code conflict

<script> var a = ' I'm a global variable a'; + function () { var a = ' I immediately execute the variables in the function a' alert(a); }(); alert(a);</script>



Refer to the answer 2:



Refer to the answer 3:

Define a div, Update dynamically div What's in the label .




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030239523111.html

Random recommended