tags:

views:

23

answers:

1

I am trying to find a solution how to grab a text from one part of the page to be displayed on a different part of the same page (not stored).

To explain this easier. I have this:

<div id="test"> hello world </div>

I want to grab the text "hello world" and display it somewhere else on the website as well.

Im thinking that there might be a javascript code that could grab that specific div text?

Any help would be very appreciated.

+1  A: 
var text = document.getElementById('test').innerHTML;

and to place it on some other part of the page:

<div id="otherpart"></div>

you could set the innerHTML:

document.getElementById('otherpart').innerHTML = text;
Darin Dimitrov