textarea自动高度 笔记221106
<textarea id=ttaa010 style=“width:800px; height:300px; font-size:36px;”>
element.style.height = element.scrollHeight+“px”;
</textarea>
<script>
let ttaa010=document.getElementById(‘ttaa010’);
ttaa010.addEventListener(“keyup”, function(event){
ttaa010.style.height = ttaa010.scrollHeight-4+“px”;
console.info(ttaa010.style.height);
});
</script>
<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"/><title>textarea自动高度笔记2211061802</title>
<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAZCAYAAAA14t7uAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAU7SURBVEhLtZVLiBxVFIa/eldXdVVP90x3T/f0vJL4GAyC2RiyUVECUfEB6lpBXepOBUXcxMdCYkQUcREiuhJ8oyHiC6JmoQiJTsYZBTUymsfodE9numu6Hp5bMxmILhTEA3/d7nr899xz/vtfLZPgfwgd0o2f/zUuzE8bZF1J2cealX92tH73n0ItcpCReBpGL4aixulxg2pmy0MNTROspVFmHevzxe591M4l6x/+Q+jC6w/gjBDPN0Y4dPkpnjn4GLa1TqrrOroRWdA2qfcCiv3mv8eggh81eLMd0PPGee/jjzAMIyfOJ48sqbGeEKylOCxfiKwj6ArO4aZqbONmy6T2KTp2ytPDEe9sdTlbcShbJvPz8zmpCr2QygxGypKTYmXahZB6qdEUaPo6UkOjL9N+OGzydtXmj5KJY5qcKiTEcZxDhYm8HDdMZm80WTQcDKmPInRUuYVQTzK0rEb5SJvh336Vqtl8MVFkrzTs50YVd0Xn0toIYT/no9vtUi6X5ZtBKu3V+HFuloW57zA0UaDKLC+VRrRmMnHCprj/K5odg9mizyP1LkfGpknKFjfM1LnuyojxQsp4q0qr1aJUKqElqRArCrmeODFLb7UnpJlKVpSp01gcZvHeF6mvmiRMsbfR5/CwT7sywfZSzH23iEJKEWVpYHXYZazZJAxDyU11UZBKlhddNkNQrTDcqFEdG2eHdQm/P/QG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gs3zJX5eEDAAAAAElFTkSuQmCC"
/></head><body>
<textarea id=ttaa010 style="width:800px; height:300px; font-size:36px;">
element.style.height = element.scrollHeight+"px";
</textarea>
<script>
let ttaa010=document.getElementById('ttaa010');
ttaa010.addEventListener("keyup", function(event){
ttaa010.style.height = ttaa010.scrollHeight-4+"px";
console.info(ttaa010.style.height);
});
</script>
</body></html>
<!DOCTYPE html><html lang=“zh-CN”><head><meta charset=“utf-8”/><title>textarea自动高度笔记2211061802</title>
<link rel=“icon” href=“data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAZCAYAAAA14t7uAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAU7SURBVEhLtZVLiBxVFIa/eldXdVVP90x3T/f0vJL4GAyC2RiyUVECUfEB6lpBXepOBUXcxMdCYkQUcREiuhJ8oyHiC6JmoQiJTsYZBTUymsfodE9numu6Hp5bMxmILhTEA3/d7nr899xz/vtfLZPgfwgd0o2f/zUuzE8bZF1J2cealX92tH73n0ItcpCReBpGL4aixulxg2pmy0MNTROspVFmHevzxe591M4l6x/+Q+jC6w/gjBDPN0Y4dPkpnjn4GLa1TqrrOroRWdA2qfcCiv3mv8eggh81eLMd0PPGee/jjzAMIyfOJ48sqbGeEKylOCxfiKwj6ArO4aZqbONmy6T2KTp2ytPDEe9sdTlbcShbJvPz8zmpCr2QygxGypKTYmXahZB6qdEUaPo6UkOjL9N+OGzydtXmj5KJY5qcKiTEcZxDhYm8HDdMZm80WTQcDKmPInRUuYVQTzK0rEb5SJvh336Vqtl8MVFkrzTs50YVd0Xn0toIYT/no9vtUi6X5ZtBKu3V+HFuloW57zA0UaDKLC+VRrRmMnHCprj/K5odg9mizyP1LkfGpknKFjfM1LnuyojxQsp4q0qr1aJUKqElqRArCrmeODFLb7UnpJlKVpSp01gcZvHeF6mvmiRMsbfR5/CwT7sywfZSzH23iEJKEWVpYHXYZazZJAxDyU11UZBKlhddNkN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m6vLuKaUW0attpNBrUazX+BPgs3zJX5eEDAAAAAElFTkSuQmCC”
/></head><body>
<textarea id=ttaa010 style=“width:800px; height:300px; font-size:36px;”>
element.style.height = element.scrollHeight+“px”;
</textarea>
<script>
let ttaa010=document.getElementById(‘ttaa010’);
ttaa010.addEventListener(“keyup”, function(event){
ttaa010.style.height = ttaa010.scrollHeight-4+“px”;
console.info(ttaa010.style.height);
});
</script>
</body></html>