Textarea enables scrolling, so if the number of characters is large, the height of the textarea itself and the height of the contents will change.
Is there a way to get the height of this content?
javascript jquery jquery-ui
$('textarea').scrollTop()+$('textarea').innerHeight()
I guess so...
You can retrieve it at Element.scrollHeight
.
var area= document.getElementById('area');
var contentHeight=area.scrollHeight;
alert('The content height is'+contentHeight+'px.');
if(confirm('Do you want to adjust the element height?)')) {
area.style.height=contentHeight+'px';
}
<textareaid="area" style="width:250px;height:100px;overflow-y:scroll;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus nisi sem, sodales ac dolor quis, elementum varius massa. Sed eget odio tincidunt, dignissim justo eget, tempus est. Cras imperdiet tempus metus a mattis. Nullam pretium ultricies sapien sit amet iaculis. Integer eget dignissim odio, non ullamcorper augue. Pellentesque a interdum sapien. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per acceptos himenaeos. Intortorrisus, elementum non conque sed, brandit neccu. Nam laoreet tincidunt effectur.
</textarea>
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.