• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

141
Views
When using query selector element.scrollHeight stops working

I have some javascript that moves the scroll bar to the bottom for a chat program I am building. It worked fine but I converted to a template with cloneNode and it no longer works. The DOM shows the scrollHeight on the element working and the querySelector is picking the correct element. I've also tried manually setting element.scrollTop to a number and it has no effect. Any ideas?

Here is my code.

            let message_template = document.getElementById('message_template');
            let message_clone = message_template.content.cloneNode(true);

            //Move scroller to bottom when clicked
            let myDiv = message_clone.querySelector(".chat-history");
            console.log('myDiv: '+myDiv.scrollHeight)
            myDiv.scrollTop = myDiv.scrollHeight;
about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error