I\'m working on a BBCode editor and here is the code:
var txtarea = document.getElementById(\"editor_area\");
function boldText() {
This is a little OT, but if anyone is interested:
setSelectionRange()
from @ashkan nasirzadehExample call: setTextCursor(textarea,textarea.val, 0, 1);
// @brief: set cursor inside _input_ at position (column,row)
// @input: input DOM element. E.g. a textarea
// @content: textual content inside the DOM element
// @param row: starts a 0
// @param column: starts at 0
function setTextCursor(input, content, row, column){
// search row times:
var pos = 0;
var prevPos = 0;
for( var i = 0; (i lineEndPos-pos)){
// go *only* to the end of the current line
pos = lineEndPos;
} else{
// act as usual
pos += column
}
setSelectionRange(input, pos,pos);
}