Home > front end >  JavaScript in the document. The createElement method (' img) and the new Image () what is the d
JavaScript in the document. The createElement method (' img) and the new Image () what is the d

Time:10-11

Both methods can create img tags, but specific have what different?
I only know 1, some old version of the browser does not support the new Image (); 2, when creating more img tags, new Image () with good performance, faster,
Other places have what different? thank you

CodePudding user response:

Should be the same

CodePudding user response:

The Image () constructor creates a new HTMLImageElement instance.

It is functionally equivalent to the document. The createElement method (" img ").
The function is equal, there is no other difference, from the MDN document

CodePudding user response:

Found a difference, the new method to create the img will automatically add width and height properties, while the createElement method not create img.

CodePudding user response:

reference weixin_45804046 reply: 3/f
, found a difference between the new method to create the img will automatically add width and height properties, while the createElement method not create img.
oh oh, severe cough up
  • Related