<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>new Image</title> </head> <body> <script src="../20180509/jq.js"></script> <script> var img = new Image(); callback = function(){}; img.onload = function () { if (img.complete) { console.log(img.width) console.log(img.height) callback(img.width, img.height); } console.log(222) callback(img.width, img.height); $("body").append(img); }; img.src="../images/01.jpg"; // 原生方法 // img.addEventListener("click",function(){ // console.log("click"); // }) // jq方法 $(img).on("click",function(){ console.log("click"); }) </script> </body> </html>