Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js tab in textarea

document.querySelector('#textarea').addEventListener('keydown', e => {
	if ( e.key === 'Tab' && !e.shiftKey ) {
		// execCommand operations are "Cmd|Ctrl+Z"-able
      	// note: execCommand is deprecated and may not work in the future
		document.execCommand('insertText', false, "	");
		e.preventDefault();
		return false;
	}
});
Comment

add tab to textarea javascript

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

tab adds tab textarea javascript

$(document).delegate('#textbox', 'keydown', function(e) {
  var keyCode = e.keyCode || e.which;

  if (keyCode == 9) {
    e.preventDefault();
    var start = this.selectionStart;
    var end = this.selectionEnd;

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

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

PREVIOUS NEXT
Code Example
Javascript :: isotope cdn 
Javascript :: mathjax new line 
Javascript :: js click on button 
Javascript :: js arithmetic operators 
Javascript :: redirect in vue 
Javascript :: how to get on click id in event 
Javascript :: javascript sum digits in string of numbers 
Javascript :: javascript getting input from console 
Javascript :: uploading file with fetch 
Javascript :: node print variable 
Javascript :: eintegrity npm error 
Javascript :: Group array of strings by first letter 
Javascript :: how to get element by id in node js 
Javascript :: percentage formula in javascript 
Javascript :: get current location url javascript 
Javascript :: Map in Javascript in LWC 
Javascript :: get home dir in nodejs 
Javascript :: jquery mobile or desktop 
Javascript :: next js start 
Javascript :: Update multiple documents by id set. Mongoose 
Javascript :: javascript write to text file 
Javascript :: max size input file html 
Javascript :: file upload in jquery 
Javascript :: json data 
Javascript :: check if object has method javascript 
Javascript :: input event on value changed 
Javascript :: print all days names of a month 
Javascript :: file extension name in js 
Javascript :: javascript calculator 
Javascript :: upload preview image js 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =