これはあなたのコードは次のようになりますどのようにあるべきである(またJSFiddle参照):// materializecss:
var rows = 4;
var cols = 32;
var body = document.body;
var ta = createElem(body, 'textarea');
var div = createElem(body, 'div');
ta.rows = rows;
ta.cols = cols;
ta.addEventListener('keyup',() => {
var lines = ta.value.split('\n');
lines = lines
.slice(0, Math.min(lines.length, rows))
.map(line => line.substring(0, cols));
ta.value = lines.join('\n');
displayRemaining(cols * rows - ta.value.length + rows - 1);
});
displayRemaining(cols * rows);
function createElem(a, b){
b = document.createElement(b);
a.appendChild(b);
return b;
}
function displayRemaining(a){
div.innerHTML = 'Characters remaining: ' + a + '.';
}
あなたは出発点はhttpとしてmaterializecssのテキストエリアを見ることができます。 com/forms.html – eavidan
@eavidanリンクに感謝しますが、私はそれが明確なjavascriptソリューションであることに注意しなければなりませんでした –