v0.1

Benutzerdefinierte Felder
#Nr. 99 - Benutzerdefinierte Datei-Eingaben
Verwandeln Sie alles in eine Dateieingabe!
Vergrößern oder verkleinern Sie die Höhe einer Textarea je nach ihrem Inhalt.
Watch the video for step-by-step implementation instructions
<!-- 💙 MEMBERSCRIPT #102 v0.1 💙 RESIZE TEXTAREA VERTICALLY -->
<script>
document.addEventListener('DOMContentLoaded', function() {
const elements = document.querySelectorAll('[data-ms-post="content"], [ms-code-resize-input="height"]');
elements.forEach(element => {
if (element.tagName.toLowerCase() === 'textarea') {
element.addEventListener('input', function() {
autoResize(this);
}, false);
}
});
function autoResize(element) {
const maxHeight = parseInt(getComputedStyle(element).maxHeight, 10);
element.style.height = 'auto';
element.style.overflow = 'hidden'; // Prevents scrollbar appearance during height adjustment
if (element.scrollHeight > maxHeight) {
element.style.height = `${maxHeight}px`;
element.style.overflow = 'auto'; // Adds scrollbar when content exceeds max height
} else {
element.style.height = `${element. propscrollHeight}px`;
}
}
});
</script>wahrAdd these data attributes to your HTML elements in Webflow. For example: <div data-attribute="value">
More scripts in Custom Fields