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 8855363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:07:05+00:00 2026-06-14T14:07:05+00:00

I can get the following simple scenario to work: A div on the page

  • 0

I can get the following simple scenario to work:
A div on the page that when clicked will open a video using JW Player in an overlay window by FancyBox. Here is a stripped down code:

HTML:

<div>
    <a class="play_video" href="#" rel="/bin/video.mp4">Click to Watch Video</a>
</div>

jQuery:

$(document).ready(function() {
    $(".play_video").fancybox({
        content: '<div id="video_container" style="width:640px;height:381px;">Loading the player ... </div> ',
        afterShow: function()
            {
                var myVideo = $(".play_video").attr("rel");
                jwplayer("video_container").setup({
                    flashplayer: "/bin/player.swf",
                    file: myVideo,
                    width: 640,
                    height: 380,
                });
            }
    });
});

Here is my problem: if I want to display two DIVs each playing a different video how do I change the line

myVideo = $(".play_video").attr("rel")

to be dynamic and selecting the rel attribute of the right div. For example, the second div would look like:

<div>
    <a class="play_video" href="#" rel="/bin/another_video.mp4">Click to Watch a different Video</a>
</div>

I hope this is clear! Thank you for your 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-06-14T14:07:07+00:00Added an answer on June 14, 2026 at 2:07 pm

    The problem with the .attr() method is that it gets the attribute value for only the first element in the matched set. To get the value for each element individually, you may have to use the method .each()

    To make it actually work without looping through your links, you could set the video reference inside the href attribute (the proper way to work) and tweak your code this way :

    html

    <a class="play_video" href="/bin/video.mp4">Click to Watch Video</a>
    <a class="play_video" href="/bin/another_video.mp4">Click to Watch a different Video</a>
    

    script

    $(document).ready(function() {
     $(".play_video").on("click", function(){
       $.fancybox({
         content: '<div id="video_container" style="width:640px;height:381px;">Loading the player ... </div> ',
         afterShow: function(){
            var myVideo = this.href;
            jwplayer("video_container").setup({
              flashplayer: "/bin/player.swf",
              file: myVideo,
              width: 640,
              height: 380,
            }); // jwplayer setup
         } // afterShow
       }); // fancybox
       return false; // prevents default 
     }); // on
    }); // ready
    

    NOTE: .on() requires jQuery 1.7+

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the unix dig command, I can get the following MX record: $ dig
I can't get the following properties to work :/ mail mailNickname name cn dn
I tried following the instruction s but can't get the plugin to work, the
This seems really simple, but I can't get the syntax correct w/ the following
this seemed simple at first but I can't get it to work. I have
I have (what I feel to be) a very simple scenario that I can't
It seems as though my scenario is about as simple as it can get.
From windows event viewer I can get the following xml structure: <Event xmlns=http://schemas.microsoft.com/win/2004/08/events/event> <System>
How can I get the following test to pass with NHibernate? I thought it
This is basic stuff but I can't get this following form to process reliably.

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.