Can someone please help with converting this code to plain JS:
$(document).ready(function() {
$("textarea").bind("keydown", function(event) {
var textarea = $(this).get(0);
//further will need only textarea and event vars
}
});
I don’t care about cross browser compatibility as long as it works in current FF and Chrome.
Your selector is quite simple, you are looking for all the
textareaelements, then you can use thedocument.getElementsByTagNamemethod.To simulate
$(document).ready, we can bind theDOMContentLoadedevent e.g.:For CSS selectors, you can use the
querySelectorAllmethod, available on both browsers you are targeting.See also: