0

I have this code segment that takes all the pictures in the page and goes through each picture showing it.

var index=0;
function changeBanner(){ 
  [].forEach.call(document.images,function (v,i) { document.images[i].hidden = i!==index});
  index = (index+1) % document.images.length;
}
window.onload = function () {
  setInterval(changeBanner, 1000)
};

I was wondering if there was any way to make this local to only one 'div' tag.

Thank You!

Pramod S. Nikam
  • 3,957
  • 4
  • 31
  • 56
  • `document.images` is ancient and deprecated, don't use it. Give your `
    ` an `id="someID"` attribute, and access it using `document.getElementById()`.
    – The Paramagnetic Croissant May 05 '14 at 06:16
  • 2
    Avoid answering questions in the comments @user3477950 – Brendan May 05 '14 at 06:18
  • @Brendan Given that there are "experienced" "programmers" who give answers which prove that [they cannot differentiate between actual implementation details and abstract semantics](http://stackoverflow.com/questions/23460405/initialization-makes-integer-from-pointer-without-a-cast-enabled-by-default/23460490#23460490), I didn't feel it was worthwhile to answer a question like this (especially because the question and the answer are both trivial). – The Paramagnetic Croissant May 05 '14 at 06:20
  • 1
    True, but other users can still benefit from a well made answer @user3477950 – Brendan May 05 '14 at 06:21

0 Answers0