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

  • Home
  • SEARCH
  • 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 8237397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:27:29+00:00 2026-06-07T19:27:29+00:00

I found the answer in another Stack Overflow Q when I did a slightly

  • 0

I found the answer in another Stack Overflow Q when I did a slightly different search. The key line of code is this:

var videoFile = $(this).find('.vid_file').text();

with ‘this’ referencing each videoLink div, then it finds the vid_file div within videoLink, and reads the text. Hopefully that will help someone else!

I am creating a dynamic video gallery with HTML, XML and JQuery. After reading in the XML file, I output an HTML string that creates a dynamic div for each video (.videoLink). Within that div are child divs that hold the video caption, a path for the background .jpg, and the name of the video file (.vid_file). All of that is working correctly. But I am having problems extracting the unique value of each .vid_file (I’ve got 6 test videos in my dbase). Here is the code I’m using:

$('.videoLink').click(function(e){
    e.preventDefault();
    $('vid_file').each(function (){
    var videoFile = $(this).text();

    var videoCode = '<video controls autoplay autobuffer>' +
        '<source src="video/'+videoFile+'.ogv" type="video/ogg" />' +
        '<source src="video/'+videoFile+'.mp4" type="video/mp4" />' +
        '</video>';

    $('#videoPlayer').html(videoCode);

etc. (I’m using fancybox to display the videos — that is working). What happens with the above code is that when you click on one, they all play. I realize that is exactly what i’m asking it to do with this code, but have tried many variations (nesting the click event inside an .each method; vice versa, and more) and getting them to play at all is the closest I’ve been to making it work. So I think I’m nearly there. But not quite. What am I missing? Thanks in advance for your help. — Cheryl

  • 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-06-07T19:27:30+00:00Added an answer on June 7, 2026 at 7:27 pm

    It seems you are missing the dot in the selector. So use the following.

    $('.vid_file').each(function (){
        var videoFile = $(this).text();
    
        var videoCode = '<video controls autoplay autobuffer>' +
            '<source src="video/'+videoFile+'.ogv" type="video/ogg" />' +
            '<source src="video/'+videoFile+'.mp4" type="video/mp4" />' +
            '</video>';
    
        $('#videoPlayer').html(videoCode);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I searched and found this question but did not like the answer. Is there
I am testing an example snippet that I found as an answer on another
I found this answer to this question https://stackoverflow.com/a/7244888/1473523 , but in my situation am
I found this answer and it sounds like almost exactly what I'm doing. I
I've found an answer to a previous question about javascript short hand for this
I have found this answer really useful. It helps me plot network/graphs and select
I haven't exactly found the answer to this, maybe there is no best one.
I looked around but haven't found an answer to this. I have a CentOS
I see a lot of people have this problem, but none answer I found
I haven`t found answer to my question using search, though I thought it is

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.