How to get the content of an editable div in javascript

This time we will talk about javascript, our second favourite language.

Did you know that you can create an editable div? Let’s see how to use it and how to get the inner html of the div and print it in another div. It could be useful.

	<script>
function inner(id){
	console.log("...")
	div = document.getElementById(id);
	space = document.getElementById("space");
	div.innerHTML = space.innerHTML;
}		
	</script>
<div id="space" contenteditable="true" >I'm a cool editable div ;)</div>
<button onclick="inner('write')">Click</button>
<div id="write"></div>
you can edit the div on top, clicking you copy what you wrote in another div below the button

Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.