3 - linzhig/js.dm GitHub Wiki
<html lang="en"> <head> <meta /> <meta /> <meta /> &lt;title&gt;Document&lt;/title&gt; &lt;style&gt; #box&#123; width: 100px; height: 100px; background: rgb(23, 97, 158); &#125; &lt;/style&gt; &lt;script src=&quot;../JS\1.js&quot;&gt;&lt;/script&gt; </head> <body> <div id="box" style="width: 200px;"> <p>123</p> </div> &lt;script&gt; //var 全局变量 会成为window属性 //let 叫做 变量 // const 常量 //div .有个事件 = 记录事件 // document.getElementById(&quot;box&quot;).onclick = function () &#123; // document.getElementById(&quot;box&quot;).innerHTML = 'ssss' // &#125; // let b1 = document.getElementById(&quot;box&quot;); // b1.onmouseover = function () &#123; // b1.style.width = &quot;500px&quot; // console.log(b1.style.width ); // &#125; &lt;/script&gt; </body> </html>
JS window.onload = function () {
let p1 = document.getElementById("p1");
let b1 = document.getElementById("box");
b1.onmousemove = function () {
p1.innerHTML = "<a href='https://www.baidu.com'>百度</a>"
} }