Search code examples
javascriptwysiwyg

Simple WYSIWYG not working, reason unknown


My wysiwyg stopped working and I can't find what's causing the problem, here is a fiddle showing the basic (not working) behavior..

http://jsfiddle.net/z5LL2n6n/

The basic code is:

<div class="icon-italic" onclick="document.execCommand('italic',null,false);">ITALIC</div>

Can someone help?


Solution

  • You should try change the click elements to be button instead of div. When you click the div, it deselects the text so there's nothing to highlight.

    http://jsfiddle.net/z5LL2n6n/1/

    <button class="icon-bold" onclick="document.execCommand('bold',null,false);">BOLD</button>
    <button class="icon-italic" onclick="document.execCommand('italic',null,false);">ITALIC</button>