<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片的onload事件</title>
    <style>
        .figure-wrapper { width: 400px; margin: 50px auto; font-size: 0; border: 1px solid red; background: #eee; text-align: center; }
    </style>
</head>
<body>
    <div class="figure-wrapper">
        <img onload="handleOnload()" width="100%"
            src="http://p.qpic.cn/music_cover/Biax4WTSMic4N0bgPWDwUCs9vvcm0PTev0Uz7IicxbKI9ajTkOUsubp5g/600?n=1" alt="">
    </div>
    
    
</body>
<script>
    function handleOnload() {
        // ...Do something
        var txt = "img onload";
        var divNode = document.createElement("div");
        divNode.style = "text-align: center";
        divNode.innerHTML = txt;
        document.body.append(divNode)
    }
</script>
</html>
warm-up

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
猜你喜欢
  • 2021-12-07
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2023-01-22
  • 2022-12-23
相关资源
相似解决方案