Forums

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

Home Forums JavaScript Most effective way to iterate with JavaScript

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #39282
    Algeo
    Participant

    Hi Guys

    I’m sure that this is obvious, but as a newcomer to any sort of programming my restricted mindset is not letting me see it.

    What is the most effective way in JavaScript to iterate through a number of things. The example I have in mind specifically is that I need one DIV to be seen at any one time (see example: http://www.algie.co.uk/test/show_and_hide_testV2.html). So when a link is clicked the DIV associated with that link appears and everything else disappears. I can’t help feeling that it is very simple and whilst my clumsy work so far kind of works, it doesn’t appear very smooth.

    Obviously as the items grow the way I am approaching it becomes unworkable very quickly and I can’t help but feel that I am missing some fundamental way of doing things!

    Any help or advice would be much appreciated.

    #107569
    timmey
    Member

    maybe this can be a starting point
    http://jsfiddle.net/BLwgJ/258/

    you can use siblings() to hide the other divs.

    #107587
    TheDoc
    Moderator

    Updated: http://jsfiddle.net/BLwgJ/259/

    Don’t need the each().

    #107772
    Algeo
    Participant

    Thanks very much.

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