javascript - document.execCommand not being executed -


this tough 1 me.

got conenteditable div formating buttons. 1 of these "bold" button:

<li data-role="button" data-button-role="bold"><b>b</b></li> 

in javascript got little peace of code:

$(document).ready(function(){     $("[data-role='button'][data-button-role='bold']").click(toggleboltformat); }); function toggleboltformat() {     document.execcommand("bold", false, null); } 

this things called (tested alert()), execcommand line not being executed. highlighted text not getting bold.

can problem relativ , absolut position of parent element of ce-div?

when putting docuement.execcommand line in chromes js-console, works fine.

try add similar html's unselectable="on" behavior. created class called unselectable , added <li>:

<li data-role="button" data-button-role="bold" class="unselectable"><b>b</b></li> 
.unselectable {    -moz-user-select: -moz-none;    -khtml-user-select: none;    -webkit-user-select: none;    -o-user-select: none;    user-select: none; } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -