code-
var main1 = document.querySelector("#main1"); var a1=document.getElementsByClassName("a") var img1=["images/11.jpg","images/12.jpg","images/13.jpg","images/14.jpg","images/15.jpg","images/21.jpg","images/22.jpg","images/23.jpg","images/24.jpg","images/25.jpg","images/26.jpg"] function slide_img(){ for(var i=0;i<a1.length;i++){ a1[i].innerHTML="<img src="+img1[i]+" width='img.naturalWidth' height='150px'>" } } function right(){ var l=img1.shift() img1.push(l) slide_img() } This function works correctly only in console.log when calling a diva through the identifier main1, it only displays this
<div class="a" id="main1"></div> and if an image is inserted into html, then for some reason it does not change in the console, I need to access the content in order to use indexOf
<>"insert code snippet"Ctrl+Min the opened window there will be three sections for html, js, css into which you can paste your code Layout styles. This allows you to add a working example directly to the question. fiddle is the same, but on a third-party jsfiddle site - Grundy