Adding an unordered list to a different division using JQuery

I currently have this DIV:

    <div id="video_container" class="barra">
        <ul>
            <li><iframe width="450" height="253" src="//www.youtube.com/embed/Gy3lrgVakII" frameborder="0" allowfullscreen></iframe></li>
            <li><iframe width="450" height="253" src="//www.youtube.com/embed/AnwKqlhzCM4" frameborder="0" allowfullscreen></iframe></li>
            <!-- more iframe elements here -->
            <li><iframe width="450" height="253" src="//www.youtube.com/embed/NKzwcbidanM" frameborder="0" allowfullscreen></iframe></li>
        </ul>
    </div>
<div id="video_container_mobile"></div>

I am looking to duplicate the content of the first div into another div with the same structure (<ul>...</ul> )

To achieve this, I have the following script:

var list = $("#video_container_mobile").append('<ul></ul>').find('ul');
        $("#video_container ul li").each(function() {
            var el = $(this);
            list.append(el);
        });

While this script successfully copies the content, it also removes it from the original div.

Please refer to the image below for a visual representation:

You can test the functionality in this JSFiddle:

http://jsfiddle.net/YgQJM/

If anyone has a solution on how to keep the same content in both DIVs, your assistance would be highly appreciated.

Answer №2

Maybe not as polished as @Hussein's, yet

$('#mobile_video_container').append($('#video_container').html());

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble loading a model with GLTFLoader in Vue2

I am utilizing GLTFLoader to import a model into my Vue2 application. My implementation follows the standard Three.js template. I directly copied the GLTFLoader code from the Three.js documentation. Despite creating a simple example, I am facing difficulti ...

What strategies can be employed to enhance the natural movement of dots on my HTML canvas?

Check out my code pen here I'm looking for feedback on how to make the movement of the canvas dots more fluid and liquid-like. I've experimented with restricting the direction for a certain number of renders (draw()), which has shown some impro ...

Attempting to employ the HTML5 file picker feature within the AppMaker platform

Hey there, I'm currently working on integrating the HTML5 file picker into my AppMaker app. (Since my app needs to run as the developer, I can't use Drive Picker). I've been able to display the file picker in an HTML widget using the follow ...

What is the process for creating this image using HTML and CSS?

Looking to style an image using HTML and CSS. This is what I attempted: <span>$</span><span style="font-size: 50px;">99</span><span style="vertical-align: text-top;">00</span> However, the result doesn't ma ...

Transforming retrieved data into an array using Node.js

Got some data from a URL that looks like this: data=%5B1%2C2%2C3%2C4%2C0%5D which when decoded is [1,2,3,4,0]. Used the snippet below to parse the data: var queryObj = querystring.parse( theUrl.query ); Seems like it's not an array. How can I con ...

Leveraging the power of Ajax, jQuery, and JSON within the CakePHP

In the realm of cakephp 1.3, I am seeking to breathe life into a <div> within my form (*.ctp) by populating it with data retrieved from a mysql table. Despite delving into numerous examples on this platform, none seem to reveal the full picture. The ...

Using a number input with step increments of 0.01 in AngularJS can result in undefined values for specific inputs

An issue arises when using a specific type of input in angularjs (1.6.1) where the values between 9.03 to 9.05 inclusively return undefined. This problem also occurs with other values like 9.62, 9.63, and 17.31. <input type="number" step="0.01" data-ng ...

Creating a single Vuetify expansion panel: A step-by-step guide

Is there a way to modify the Vuetify expansion panel so that only one panel can be open at a time? Currently, all panels can be closed which is causing issues. I would like the last opened panel to remain open. I also want to prevent closing the currently ...

Display unique information according to the value in the form field (email domain)

I've developed an innovative ajax signup form that integrates jQuery and CSS3. The unique feature of this form is its multi-step process. In the first step, users are required to enter their email address and password. What sets this form apart is i ...

Can all strings in an array be substituted, leaving only one unchanged?

Here is the list I have: [ '030', '040', '050', '060', '070', '080', '090', '100', '110' ] I am wondering if it's possible to replace all zeros with nothing exc ...

Is there a way to conceal every element tag with just a single id name?

I am attempting to conceal specific tags by utilizing a single ID element, but it appears that it only hides the first tag associated with the ID element I used. Here is a demonstration: http://jsfiddle.net/mgm3j5cd/ How can I resolve this problem? I wan ...

Direct all relative URLs to the main directory

I have implemented Redirect rules to convert queries like user/34 to user.php?id=34 The issue arises when using relative URLs in user.php. For example, image.png is now being searched relative to a non-existent folder 'user'. My current object ...

The image is loaded correctly through the image picker, however, it is not displaying on the screen

When I click the button to pick an image from the gallery in this code, it is supposed to load the phone's gallery and display the selected image in the image component. Even though the image gets loaded properly (confirmed through test logs), it does ...

What is the best way to include spacing among my Bootstrap 5 navigation components?

Looking for advice on creating space between each nav-item in a bootstrap 5 navigation bar while maintaining a clean design for phone mode. Here's the code snippet: <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi ...

developing a loading animation with progress indicator in CSS3

I have been working on creating a preloader, but I am having trouble embedding the percentage with the CSS circle. So far, I have tried various plugins without success. Can anyone help me with this issue? Here is my current progress. Below is the HTML co ...

Executing SendKeys on a div element with the attribute coleditable="true" in Selenium and C#

I am facing a challenge with an element that I am unable to input text into. <div class="floatstart gridcell grideditablefield" colname="Items" coltype="string" coleditable="true" val="" style="widt ...

My CSS seems to be causing issues and generating errors in the console. What could be the problem?

My CSS was working fine just 5 minutes ago, but now it's not working and I'm not sure what the issue is. I checked the console and found this error: bootstrap.min.js:6 Uncaught TypeError: Cannot read property 'fn' of undefined at bo ...

`Open PhotoSwipe to view the image in a new window`

My goal is to open the current visible photo in a new window using JavaScript, while ensuring it works on an iPad as well. To achieve this, I added a button to the toolbar (similar to the example) and included its corresponding CSS in the photoswipe.css fi ...

Filtering an Array object by comparing it with another Array object

Having two arrays in different formats: var array1 = [{ "Name": "Test1", "id": 3 }, { "Name": "Test2", "id": 4 }]; And the other one: var array2 = [{ "visible": "true", "id": 1 }, { "visible": "true", "id": 2 }, { "vi ...

Having trouble with the "Corrupted @import" error during grunt build?

As I embark on my journey to create my very first Angular application, I have encountered a roadblock. Using Yeoman and angular-generator, everything seemed to be running smoothly with "grunt serve." However, when I attempted to execute "grunt build," the ...