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

  • The carousel is not done at all ... - Qwertiy ♦
  • This is not the case (and so far so I can), but the fact is that I can not extract the data, but I had to work in my opinion - Tigran
  • Make a snippet or fiddle. - Qwertiy ♦
  • I have been learning javascript for a month, these terms are not familiar to me (googled, looked but it is better to leave for later) differently, how can I do it, and what is my mistake? - Tigran
  • 2
    @Tigran, a snippet is an example that you can run and see the problem, in the editing mode in the question editor there is a button <> "insert code snippet" Ctrl+M in 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

0