I have div
tag with contentEditable = 'true'
. When I enter text from my keyboard and then call the undo
function (document.execCommand('undo',false, null)
), all of the text I entered is deleted. I want to just undo the last character typed. How can I do that?
function doUNDO()
{
document.execCommand('undo',false, null);
}
<!DOCTYPE html>
<html>
<head>
<script src="formulas.js"></script>
<link rel="stylesheet" href="styles.css" type="text/css" media="screen" />
</head>
<body id="main" spellcheck="false">
<span contenteditable="false">
<button onclick="doUNDO()">UNDO</button>
</span>
<div id = "mainDiv"contenteditable="true">a</div>
</body>
</html>