tab adds tab textarea javascript
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, "\t");
e.preventDefault();
return false;
}
});$(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)
+ "\t"
+ $(this).val().substring(end));
// put caret at right position again
this.selectionStart =
this.selectionEnd = start + 1;
}
});
Also in JavaScript:
- redirect to homepage javascript
- make web page refresh on javascript
- select the first elemnt have class in jquery
- lodash deep compare two objects
- .empty() in jquery
- js switch case
- vowel
- first remove active class from classlist and append to current element using javascript
- fs writefile node
- angular add bootstrap
- IFFI in js
- js object random key
- get only one type from json
- retour à la ligne react native
- add two numbers javascript
- js date add 1 day
- get value of input jqueyr
- javascript bind this syntax
- is undefined javascript
- import a script to my react componetn
- check checkbox based on value using jquery
- json file example
- if i pass an object to a function is it the same object javascript
- nodejs check if variable is undefined