Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3668362
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:06:48+00:00 2026-05-19T02:06:48+00:00

I guess I have just hit a mental block with this one; maybe some

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:06:48+00:00Added an answer on May 19, 2026 at 2:06 am

    In addition to @p.campbell’s solution. I’m not sure how your code is going to work.

    var o = $('.menu-item')

    will always return the same amount of items, namely the number of items with menu-item as the class. Why not set an attribute like filename to whatever the appropriate value is. Like so

    <li class='menu-item' filename='letters'>Letters</li>
    

    and then in your click handler you can do

    var filename = $(this).attr('filename');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok another WPF question, well I guess this is just general .NET. I have
Strange Question i guess but i have this bit of code in my page...
Just wanted to ask some advice when building a database with mongodb, I have
I'm using Visual Studio 2008 and I have just noticed that the debugger is
This is just freakin weird to me. So if I don't function BindAlbumAndPhotoData() {
I guess my question is in understanding the $_POST handling. So I have two
Guess people need some experience with Linq-to-xml and knowledge of the build of a
This is probably really simple. But I guess I'm too new to WSGI and
I have just set up a new ASP.NET MVC website and I would like
I have hit a problem with the Perfarce extension that I can’t seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.