Search
 
SCRIPT & CODE EXAMPLE
 

HTML

html textarea along with cursor position set

document.getElementById('bold').addEventListener('click', boldText);

function boldText() {
  var txtarea = document.getElementById("editor_area");
  var start = txtarea.selectionStart;
  var end = txtarea.selectionEnd;
  var sel = txtarea.value.substring(start, end);
  var finText = txtarea.value.substring(0, start) + '[b]' + sel + '[/b]' + txtarea.value.substring(end);
  txtarea.value = finText;
  txtarea.focus();
  txtarea.selectionEnd= end + 7;
}
Comment

PREVIOUS NEXT
Code Example
Html :: relative vs absolute path html 
Html :: html video element 
Html :: accordion html 
Html :: html css block button 
Html :: close hamburger menu fontawesome 
Html :: html single line comment 
Html :: what does ul mean html 
Html :: html definition list 
Html :: px in server is different from html file 
Html :: select country dropdown with flag 
Html :: html tables 
Html :: typo3 symlinks 
Html :: image slider with bootstrap 
Html :: prefill input field html 
Html :: html small text 
Html :: progress-bar-success bootstrap 4 
Html :: bootstrap input field validation 
Html :: anchor html 
Html :: HTML5 Video tag not working in Safari , iPhone and iPad 
Html :: index.html is stored in folder github 
Html :: convert rtf to html 
Html :: how to highlight any text in html and css 
Html :: coreui margin right 
Html :: how to create animated text in html 
Html :: bootstrap 4 tabs 
Html :: how to add html in useState 
Html :: collapse bootstrap 
Html :: html entity question mark 
Html :: react createContext usage 
Html :: object to string angular html 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =