There is an array of images:
var slide = new Array(); slide[0] = new Image(); slide[0].src = "photo0"; slide[1] = new Image(); slide[1].src = "photo1"; And so I tried to display it on the page:
<img name="myImg"> document.images["myImg"].src = slide[0].src; But it shows a white square, torn in the middle. Tell me, please, what is wrong?
new Image();meansnew Image();eg? Or, for example, tell me why the presence of the stringphoto0in thesrcattribute should display a picture? - Alexey ShimanskyПеременной присваивается это new Image(),- what exactly happens whennew Image()you do not know? because judging by the recorddocument.images["myImg"].src = slide[0].src;definitely don't know. Although somewhere read about new Image () ........а потом в виде var photo.src = "Here is path" добавляется картинка.- Nuuuu let's say ... well, and where does yourphoto0? - Alexey Shimanskynew Image()creates a new DOM element. If specifically, the picture. If you embed this construct in the console, you will see<img>. Hence the first step and the question: in the end, do you want to insert the path to the image into the already created<img name="myImg">element? then manipulations with new Image () are unnecessary ........... or still create dynamically? then<img name="myImg">absolutely not needed here - Alexey Shimansky