I'm trying to enable the tabulation module in my project. Working module I took from http://css-tricks.com/snippets/javascript/support-tabs-in-textareas/ , but when I add this .js to my project i get the following error:
Uncaught TypeError: Cannot set property 'onkeydown' of undefined.
Its work when i run it on http://jsfiddle.net/zQgTx/ but doesnt work, when I run it in my project. Using jquery-1.9.1. My html code:
<form method="POST" action="." class="navbar-form">
<textarea id="answer" name="answer" style="width: 700px; height: 250px;"></textarea>
<br><input class="btn btn-primary" type="submit" value="Check">
</form>
Help solve the problem. Thanks!
Wrap all your code in onload function like this:
window.onload = function(){
// Your code;
}
Issue happens because when this line runs :
var textarea = document.getElementsByTagName('textarea')[0];
your textarea is not actually loaded. onload will solve it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With