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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:07:13+00:00 2026-05-14T01:07:13+00:00

I have two divs. I would like to move/populate the text from div id

  • 0

I have two divs. I would like to move/populate the text from div id one to div id two using an onclick event. I am wondering how to do this? and also whether mootools can be used to accomplish the task or whether simple javascript is only necessary?

<script type="text/javascript" src="js/mootools.js"></script>

<script type="text/javascript">
alert($('side-a'));
function my_function(){
    var originalDivHtml = document.id('one').get('html');
    document.id('two').set('html', originalDivHtml);
}
</script>

<div id='one'>
 <ul>
  <input type="checkbox"  onclick = "my_function()"/>
  <li>some text 1</li>
  <input type="checkbox"  onclick = "my_function()"/>
  <li>some text 2</li>
 </ul>
<div>

<div id='two'>
<div>

I have also tried like this but it doesnt still work

<div id='two'>
 <ul>
  <input type="checkbox"  onclick = "my_function()"/>
  <li>some text 1</li>
  <input type="checkbox"  onclick = "my_function()"/>
  <li>some text 2</li>
 </ul>
<div>

<div id='one'>
<div>

<script type="text/javascript">
var one = document.getElementById('one'), two = document.getElementById('two');

function my_function () {
    while (two.childNodes.length) {
        one.appendChild(two.firstChild);
    }
}

</script>

Cheers in advance for any helps. Bangin my head against a brick wall here, because my javascript skillz are limited!

Ke

  • 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-05-14T01:07:13+00:00Added an answer on May 14, 2026 at 1:07 am
    var originalDivHtml = $('one').get('html');
    $('two').set('html', originalDivHtml);
    

    or with hazelnut Javascript

    var originalDivHtml = document.getElementById('one').innerHTML;
    document.getElementById('two').innerHTML = originalDivHtml;
    

    The function should be defined as:

    function my_function() {
       var originalDivHtml = $('side-a').get('html');
       $('content').set('html', originalDivHtml);
    }
    

    You should have two elements having the ID’s side-a and content for the above.

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

Sidebar

Related Questions

I have two Divs that are floated right, but I would like one to
I have two divs, one inside the other and I would like the small
I have two floating divs. I would like the first div to be 100px
I have a div with two nested divs inside, the (float:left) one is the
I have two divs inline-table(content and sidebar) and I would like to have the
I have a simple two divs: <div id=slide_menu> <div id=tic>MENU</div> </div> And I would
I have two divs, one inner and one outer, but the inner div is
I have two divs like so <div id=parent style=width:100px:overflow:hidden;> <div id=child> tooooooooooooooooooooo much content
I have two divs, whose heights I would like to control relative to each
I have two divs placed inside a larger div. Each one of these two

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.