当元素以HTML格式完成加载后执行脚本吗?

元素加载完成后,请使用 onload属性执行脚本。

示例

您可以尝试运行以下代码来实现onload属性-

<!DOCTYPE html>
<html>
   <head>
      <script>
         function display() {
         alert("Welcome!");
         }
      </script>
   </head>
   <body onload = "display()">
      <h3>Welcome to the website.</h3>
      <p>We offer learning content.</p>
   </body>
</html>