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...

1st Jun 2020, 10:24 AM
sid
sid - avatar
2 odpowiedzi
+ 1
I don't think you can do that. Use document.createElement()
1st Jun 2020, 10:42 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 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
1st Jun 2020, 12:03 PM
ODLNT
ODLNT - avatar