jquery - Add attribute with increasing values -


i have html:

<article id="2332">content...</article> <article id="0565">content...</article> <article id="5686">content...</article> 

i want add attribute "scroll-index" increasing numbers. result, should be

    <article id="2332" data-scroll-index="0">content...</article>     <article id="0565" data-scroll-index="1">content...</article>     <article id="5686" data-scroll-index="2">content...</article> 

i trying jquery code:

var scrollindex = 0; $('article').each(function() {     $(this).attr('data-scroll-index', scrollindex);     scrollindex++; }); 

but no accomplishment. auggestions?


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

java - SmsManager sending message more than one -