【①window.alert() : Pop up warning box 】
<script>window.alert(10*10);</script> window.alert(10+10) Will output 20, and window.alert(
"10+10") Will output 10+10.
【②document.write() : Output content to document 】
<script>document.write(Date());</script> // Output current time
If the document.write, whole HTML The page will be covered .
【③innerHTML: adopt id Attribute identification element , And then rewrite it 】
<script>document.getElementById("yun").innerHTML = " I think it's OK .";</script>
【④console.log() : Control of writing to browser 】
<script>y = 5;u = 6;h = y + u;console.log(h);</script> // click F12,console
【 Little knowledge 】
Scripts can be found in HTML Of body or head In the label , Or both . We usually put functions in head
Section or bottom of page . Scripts can also be saved in an external file , The extension is .js.
Technology