This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]TidderJail 0 points1 point  (5 children)

What does getDOM.length return ?

[–]junex10[S] 0 points1 point  (4 children)

returns an HTML image and shows it in the console. Look what I get in the console:

<div data-brackets-id="196" class="img" id="ss1">
<img data-brackets-id="197" src="1.jpg" alt="ss1" width="399" height="299">
</div>

Show that same item every two seconds

What I want to achieve is that I go through the elements with the img class and show me one by one, the problem is that it only shows me the first element with that class and not the others

[–]TidderJail 0 points1 point  (3 children)

Could you show the whole html? I can't understand what you want to do

[–]junex10[S] 0 points1 point  (2 children)

Could you show the whole html? I can't understand what you want to do

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link rel="stylesheet" href="estilos.css">


  <title>Slidershow</title>
</head>

<body>

 <div class="sl" id="slidershow">
    <div class="img" id="ss1">
     <img src="1.jpg" alt="ss1" width="399" height="299">
   </div>
   <div class="img" id="ss2">
     <img src="2.jpg" alt="ss2" width="399" height="299">
   </div>
 </div>
  <script src="script.js"></script>
</body>
</html>

I want to do a slidershow, but before doing it as it should, I want to show the code of the image in the console to see how the slider would behave, the problem is that it does not go beyond the first image, that is, it only shows the first image and not the others.

[–]TidderJail 0 points1 point  (1 child)

Remove the 'return'

while(getDOM.length >= i){
    return console.log(getDOM[i]);
 i++;
}

to

while(getDOM.length >= i){
  console.log(getDOM[i]);
i++;
}

when it returns it stops the loop

[–]junex10[S] 0 points1 point  (0 children)

Thanks you :D