Get Next and Previous Elements in JavaScript array -
I have a large array that contains non-sequential IDs, which looks like this:
Photo List [8 9 7] = New Array (); Photo List [8 9 725] ['Imaged'] = '89725'; Photo List [89725] ['Image Size'] = '123'; Photo List [8 9 726] = New Array (); Photo List [8 9 726] ['Imaged'] = '89726'; Photo List [8 9 726] ['Image Size'] = '234'; Photo List [8 9 7 7] = New Array (); Photo List [8797] ['Imaged'] = '89727'; Photo List [8 9 727] ['Image Size'] = '345'; Etc. .... I am trying to find out, given an ID, how can I get the next and previous ID ... so that I can do something like this: & lt; Div id = "current" & gt; Showing you ID: 89726 Size: 234 & lt; / Div & gt; Get pre-next
Obviously, if we are beginning or beginning the array, then we just have one message ...
Why do not you add properties to 'Previous'? 'Next' for that array?
Photo List [8 9 7] = New Array (); Flammallist [8 9 725] ['Previous'] = 89724; Photo List [89725] ['Next'] = 89726; Photo List [8 9 725] ['Imaged'] = '89725'; Photo List [89725] ['Image Size'] = '123';
This is just a 'double-linked list' data structure.
Comments
Post a Comment