javascript - Styling all elements of Array with For-Loop -



javascript - Styling all elements of Array with For-Loop -

i have div reddish border. border disappear after lets 3 seconds when page done loading. there 3 images within div , i'd them opaque 0.1 after same time. tried doing timer won't run. able border part work when seek images doesn't run , aptana says there error loop is.

function setplaylist(){ var playlist = document.getelementbyid('playlist'); var thumbnails = document.getelementsbyclassname('thumb').getelementbytagname('img'); for( var i=0,i<thumbnails.length;i++) { thumbnails[i].style.opacity = ('0.1'); } playlist.style.border = ('none'); /*thumbnails.style.opacity = ('0.1');*/ } function timerpl(){ settimeout(setplaylist,3000); } window.addeventlistener('load',timerpl,false);

this function:

document.getelementsbyclassname('thumb').getelementbytagname('img'); // ^ // \_ it's plural. it'll homecoming array of elements

you need iterate on them:

var thumbs = document.getelementsbyclassname('thumb'); (var = 0; < thumbs.length; i++) { var thumb = thumbs[i]; ... }

if don't care older browsers, utilize queryselectorall:

var thumbs = document.queryselectorall('#playlist .thumb img');

javascript arrays html5 loops for-loop

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -