css - use tab-indent when tab button is pressed in textarea but it is going to next element in html -


<textarea></textarea> 

this code need output in whenever tab placed indent right.. pressing tab else

please see following example: http://www.jqversion.com/#!/lidxmdg

you can use jquery code accomplish that:

$(document).delegate('textarea', 'keydown', function(e) {   var keycode = e.keycode || e.which;    if (keycode == 9) {     e.preventdefault();     var start = $(this).get(0).selectionstart;     var end = $(this).get(0).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 @ right position again     $(this).get(0).selectionstart =     $(this).get(0).selectionend = start + 1;   } }); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -