kQuery : Trying to find a specific instance of a class by number
Posted
by
mattelliottIT
on Stack Overflow
See other posts from Stack Overflow
or by mattelliottIT
Published on 2011-01-12T02:49:17Z
Indexed on
2011/01/12
2:53 UTC
Read the original article
Hit count: 209
I guess I have just hit a mental block with this one; maybe some fresh eyes will help.
Basically I have a few instance of the class "menu-item" which when clicked call the click function via jQuery and bring up a video. Instead of giving each on an id as well as a class I am trying to find which instance of the class was clicked (1, 2, 3, etc). Just can't seem to get it though.
//click listener for menu-items
$('.menu-item').click(function(event)
{
var o = $('.menu-item');
var count = o.length();
//
switch(count)
{
case 0 :
filename == 'letters';
break;
case 1 :
filename == 'the-gift';
break;
}
var videoPlayer = '<video controls width="618px">';
videoPlayer += '<source src="_video/' + filename + '.mp4" />';
videoPlayer += '</video>';
//place video
$('#videoCont').html(videoPlayer);
});
I'm trying to create an array there where each instance of the 'menu-item' is one array item. (btw, for now I am just proofing this with an mp4 filetype before I add in the ogv and webm formats).
Thanks for any and all help!
© Stack Overflow or respective owner