JavaScript based learning (two) js and html combination of fashion

The first

Use a label

<script type="text/javascript">  js代码; </script>

The second

Use the script tag, the introduction of an external js file

We need to create a write js file js code

<script type="text/javascript" src="1.js"></script>

The second way to use the time, no need to write js code in the script tag inside

Third:

HTML tags binding properties

<button onclick="alter("hhh")"></button>
<a href="javascript:alter('hhh');">hhh<a/>

Precautions

script tag for the introduction of an external file, you can not write another script code, even if the execution can not be written

If you need to write, you need to create another new script tag write

script tag on location

Suggested that the script into the back of the label. For example, now there is such a demand: in js inside need to get to the inside of the input value, if the script tag into the head inside problems. html parsing is parsed from top to bottom, script tag is put

inside the head, which is directly input takes a value in it. Because the page has not been resolved to input the line, be sure to get any. script code analysis from top to bottom

Guess you like

Origin www.cnblogs.com/Yee-Q/p/12315311.html