How to apply text styles like bold, italicize, and underline in div with "contenteditable" attribute?
I used,
contenteditable="true"
attribute in my elements that I want to be editable. I would like to add an option to make it Bold, Italicized, or Underlined.
I research about this and only way I found is using some plugins. I prefer not to use other plugins.
Use execCommand
.
JQuery
$(document).ready(function() {
$('#Bold').click(function() {
document.execCommand('bold');
});
$('#Italic').click(function() {
document.execCommand('italic');
});
});
Full option's link for execCommand
Almost all modern browser support it.