jQuery Grouping Similar Items w/ Object Literal

Posted by NessDan on Stack Overflow See other posts from Stack Overflow or by NessDan
Published on 2010-06-15T21:24:50Z Indexed on 2010/06/16 23:12 UTC
Read the original article Hit count: 200

Filed under:
|
|

So I have this structure setup:

<ul>
    <li>http://www.youtube.com/watch?v=dw1Vh9Yzryo</li> (Vid1)
    <li>http://www.youtube.com/watch?v=bOF3o8B292U</li> (Vid2)
    <li>http://www.youtube.com/watch?v=yAY4vNJd7A8</li> (Vid3)
    <li>http://www.youtube.com/watch?v=yAY4vNJd7A8</li>
    <li>http://www.youtube.com/watch?v=dw1Vh9Yzryo</li>
    <li>http://www.youtube.com/watch?v=bOF3o8B292U</li>
    <li>http://www.youtube.com/watch?v=yAY4vNJd7A8</li>
    <li>http://www.youtube.com/watch?v=dw1Vh9Yzryo</li>
</ul>

Vid1 is repeated 3 times, Vid2 is repeated 3 times, and Vid3 is repeated 2 times. I want to put them into a structure where I can reference them like this:

youtube[0][repeated] = 3; youtube[0][download] = "http://www.youtube.com/get_video?video_id=dw1Vh9Yzryo&fmt=36"

youtube[1][repeated] = 3; youtube[1][download] = "http://www.youtube.com/get_video?video_id=bOF3o8B292U&fmt=36"

youtube[2][repeated] = 3; youtube[2][download] = "http://www.youtube.com/get_video?video_id=yAY4vNJd7A8&fmt=36"

"This video was repeated " + youtube[0][repeated] + " times and you can download it here: " + youtube[0][download];

How can I set this multidimensional array up? Been Googling for hours and I don't know how to set it up. Can anyone help me out?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about arrays