JavaScript element Creation Doubt | Sololearn: Learn to code for FREE!


JavaScript element Creation Doubt

To create a img on ECMA we use im=new Image() right,???? But the element actually "img" and not "Image"... So is this applicable for all elements like using L=new List() for creating an "li" element...

6/1/2020 10:24:17 AM


2 Answers

New Answer


I don't think you can do that. Use document.createElement()


sid "The HTMLImageElement interface represents an HTML <img> element, providing the properties and methods used to manipulate image elements." Image() is a constructor of the HTMLImageElement interface and is from the browser, not ECMA script. While there is an HTMLLIElement interface it does not provide a constructor, MDN provides a list of Web APIs and interfaces, you should take a look.