Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<meta charset=utf-8 />
<title></title>
</head>
<body>
  <div id="myeditor" contenteditable="true">
    <p><b>My Heading 1</b></p>
    <p>&#8203;</p>
    <p>&#8203;</p>
    <p>&#8203;</p>
    <p><b>My Heading 2</b></p>
    <p>&#8203;</p>
    <p>&#8203;</p>
    <p>&#8203;</p>
    <p><b>My Heading 3</b></p>
    <p>&#8203;</p>
    <p>&#8203;</p>
    <p>&#8203;</p>
</div>
  </body>
  </html>
 
$(document).on('keydown', "#myeditor", function (e) {
var keyPressed = e.keyCode | e.which;
if(keyPressed == 8){
    //TODO: determine character to be deleted and remove it if it is ZWSP
   var range = document.selection.createRange();
    range.moveStart('character', -1);
    if(range.text === String.fromCharCode(8203))
    {
        range.text = "";
    }
}
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers