Prompt by this feature. Where to call her?
The problem: there is a textarea field, at the top of the link. When clicking on a link, the text should be formatted, but this does not happen. Here is the code:
window.onload = function () { var mainDiv = document.createElement('div'); mainDiv.id = 'mainDiv'; document.body.appendChild(mainDiv); var buttonControl = { 'paragraf': '<a href = "#paragraf" id="paragraf" class="buttonControl">p</a>', 'bold': '<a href = "#bold" id="bold" class="buttonControl">b</a>', 'italic': '<a href = "#italic" id="italic" class="buttonControl">i</a>' }; for (var property in buttonControl) { mainDiv.innerHTML += buttonControl[property]; } var mainArea = document.createElement('textarea'); mainArea.id = 'mainArea'; mainDiv.innerHTML += '<br />'; mainDiv.appendChild(mainArea); document.getElementById('bold').onclick = function (element) { mainArea.focus(); window.document.execCommand('bold', null, ''); element.preventDefault(); }; };