Click here to Skip to main content
15,923,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I would like some help with this website i am developing. I'm a newbie in web dev.
Anyway what i'm trying to do is to repeat this mark up about 10 times. But for every video element in the new markup it has a different source attribute.

So basically
1. create the markup and add it to another div with an id "content"
2. change the video tags source attribute to a new file (will get sources from .json file)
3. start again.

Here is my markup so far..

XML
<div data-role = "content" id="content" class = "content">
       <div id = MediaPlayer>
           <div class = "Media-Info">
           </div>
            <p id = "1">
                <video onclick="playVideo()" class = VideoElem  >
                    <div  class="Media-Toolbar" data-role = "navbar" data-theme="a" >
                        <ul>
                            <li><a onclick="SpawnVidElement()" href="" data-iconpos="top" data-theme="a">One</a></li>
                            <li><a href="" data-iconpos="top">Two</a></li>
                            <li><a href="" data-iconpos="top">Two</a></li>
                        </ul>
                       </div>
                   <div>
               </div>
              </video>
           </p>
       </div>



The script i have tried using is this

C#
function SpawnVidElement()
{
    var original = document.getElementById('MediaPlayer');
    var clone = original.cloneNode(true); // "deep" clone
    clone.id = "MediaPlayer" + ++i;
    clone.onclick = SpawnVidElement;
    document.getElementById("content").append(clone);
}


Thanks in advance
Posted
Comments
Sinisa Hajnal 17-Nov-14 6:17am    
So...what do you get from your code? Which part doesn't work? Adding? Changing data?
Also, consider having hidden element (display: none) that holds only template without data...that way you always get empty element ready for filling.

1 solution

JavaScript
$("#car2").clone().insertAfter("div.car_well:last");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900