Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

add tab to textarea

document.getElementById('textbox').addEventListener('keydown', function(e) {
  if (e.key == 'Tab') {
    e.preventDefault();
    var start = this.selectionStart;
    var end = this.selectionEnd;

    // set textarea value to: text before caret + tab + text after caret
    this.value = this.value.substring(0, start) +
      "	" + this.value.substring(end);

    // put caret at right position again
    this.selectionStart =
      this.selectionEnd = start + 1;
  }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: lodash partial match 
Javascript :: refresh page by hand in react 
Javascript :: conditional classname prop react 
Javascript :: node js download file to folder 
Javascript :: check if browser is internet explorer js 
Javascript :: how to use the onload event n vue js 
Javascript :: Check object property exists or not in js 
Javascript :: change title react 
Javascript :: uploading file with fetch in js 
Javascript :: how to implement redis pub sub model using nodejs 
Javascript :: jq examples 
Javascript :: immediately invoked function expression async 
Javascript :: set css var with javascript 
Javascript :: run on load js 
Javascript :: javascript hex color to rgba 
Javascript :: chalk js 
Javascript :: chartjs begin at 0 
Javascript :: javascript random number between 20 and 30 
Javascript :: quotation marks javascript 
Javascript :: how to add a class to an element in javascript 
Javascript :: node require module 
Javascript :: react lazy import non default 
Javascript :: iframe reload src 
Javascript :: add multiple class from array javascript 
Javascript :: how to icon font-awesome react cart 
Javascript :: textalignvertical not working in ios react native 
Javascript :: get all days of month javascript 
Javascript :: how to get folder names with fs 
Javascript :: javascript returning a function 
Javascript :: image preview 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =