mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
13 lines
433 B
JavaScript
13 lines
433 B
JavaScript
var textarea;
|
|
function deleteLine(ta){
|
|
let startPos = ta.selectionStart;
|
|
let endPos = ta.selectionEnd;
|
|
let text = ta.value;
|
|
let lStart = startPos-1;
|
|
while(lStart>=0 && text.charAt(lStart)!='\n') lStart--;
|
|
let lEnd = endPos;
|
|
let len = text.length;
|
|
while(lEnd<len && text.charAt(lEnd)!='\n') lEnd++;
|
|
ta.value = text.substring(0,lStart+1) + text.substring(lEnd+1);
|
|
ta.selectionStart = ta.selectionEnd = lStart +1;
|
|
}
|