Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Index in array issue

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #152910
    Kuzyo
    Participant

    Hi to everyone. My situation: I have array with 200 elements var block = document.getElementsByClassName( 'block' ); 4 of elements have additional class box. How can I set to different variables index of elements with class box. Something like:

    var first = 6 ( index of element with class box);
    var second = 67 ( index of element with class box);
    var third = 112 ( index of element with class box);
    var fourth = 189 ( index of element with class box); 
    

    Thanks for any help.

    #152971
    Kuzyo
    Participant

    Thanks @jamygolden. Your solution is very helpful, but my intention was recieve indexes, like boxes.push(i). Because of my english I couldn’t properly explain problem. Thanks again.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.