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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:03:46+00:00 2026-06-09T00:03:46+00:00

I am trying to add a new VideoJS object and set it up entirely

  • 0

I am trying to add a new VideoJS object and set it up entirely from JS, without having a DOM video element.
The result is that the video is loaded but there aren’t any VideoJS controls.
Here is the code:

obj = document.createElement('video');
                $(obj).attr('id', 'example_video_1');
                $(obj).attr('class', 'video-js vjs-default-skin');

                var source = document.createElement('source');
                $(source).attr('src', path);
                $(source).attr('type', 'video/mp4');
                $(obj).append(source);

                $("#content").append(obj);
                _V_("example_video_1", {}, function () {
                    //
                    }
                });

I will appreciate any help, thanks!

  • 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-09T00:03:49+00:00Added an answer on June 9, 2026 at 12:03 am

    Okay took a look at video-js, it’s quite nice. Try this:

    HTML:

    <html>
      <head>  
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet">
        <script src="http://vjs.zencdn.net/c/video.js"></script>
      </head>
      <body>
        <div id="content"> </div>
          <!-- appending video here -->
        <hr />
        <!-- written in html -->
        <video id="example_video_by_hand" class="video-js vjs-default-skin" controls width="640" height="264" poster="http://video-js.zencoder.com/oceans-clip.jpg" preload="auto" data-setup="{}">
         <source type="video/mp4" src="http://video-js.zencoder.com/oceans-clip.mp4">
       </video>
      </body>
    </html>
    

    JavaScript:

    var obj,
        source;
    
    obj = document.createElement('video');
    $(obj).attr('id', 'example_video_test');
    $(obj).attr('class', 'video-js vjs-default-skin');
    $(obj).attr('width', '640');
    $(obj).attr('data-height', '264');
    $(obj).attr('controls', ' ');
    $(obj).attr('poster', 'http://video-js.zencoder.com/oceans-clip.jpg');
    $(obj).attr('preload', 'auto');
    $(obj).attr('data-setup', '{}');
    
    source = document.createElement('source');
    $(source).attr('type', 'video/mp4');
    $(source).attr('src', 'http://video-js.zencoder.com/oceans-clip.mp4');
    
    $("#content").append(obj);
    $(obj).append(source);
    

    Working example on jsbin.


    Updates:

    As polarblau pointed out in a comment the jQuery.attr() can take an object rather than having to call jQuery.attr() multiple times like in my first example.

    note: The below is just an example and not a working demo.

     var attributes = {
       'id': 'example_video_test',
       'class': 'video-js vjs-default-skin',
       'width': '640',
       'data-height': '264',
       'controls': ' ',
       'poster': 'http://video-js.zencoder.com/oceans-clip.jpg',
       'preload': 'auto',
       'data-setup': '{}'
     }
    
     var element = $('<video/>').attr(attributes)
     //you would also have to add the source element etc but this gives
     //a good example of a shorter approach
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to add an element to a database and then return a new
I'm trying to add new object to existing organisational unit in Active Directory. Following
I am trying to add new methods to an object dynamicaly. Following code works
I'm trying to add new object to my ArrayList if it satisfy the condition.
I am having below html code and trying to add new values to global
suppose that in oracle 11.g database,we are trying to add new employeer,in case of
The scenario is that I am trying to add a new site column, I
Im new to asp.net mvc. I'm trying add new model class but it got
I'm trying to add a new nova-compute node (KUubuntu 12.04) to my single node
I am trying to add a new record to my internal table and this

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.