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

0

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

sid

2 Answers

New Answer

+1

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. https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement While there is an HTMLLIElement interface it does not provide a constructor, https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement MDN provides a list of Web APIs and interfaces, you should take a look. https://developer.mozilla.org/en-US/docs/Web/API

0

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