Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

63
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;
7 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

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