I know that many people have asked about tabs and textareas before, and I've seen many good answers, including the code shown below, but for some reason it has no effect on my webpage at all.
$(document).delegate('#textbox', '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;
$(this).val($(this).val().substring(0, start)
+ "\t"
+ $(this).val().substring(end));
$(this).get(0).selectionStart =
$(this).get(0).selectionEnd = start + 1;
}
});
The textarea is the only element on my page at the moment, could that be affecting it? All JS files are linked correctly with my page, and JS is enabled on my browser! Any feedback would be gratefully received!