Issue
I want to get the real height of a div class = "group-members"
in the browser console
The block continues to load when the page scrolls to the bottom
I wrote something like this to get its height:
var h = window.getComputedStyle(document.getElementsByClassName('group-members'), null).getPropertyValue('height');
window.scroll({
top: h,
left: 0,
behavior: 'smooth'
});
when I run these code it comes back
Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
So what's wrong? How can I get the height of this variable div?
Solution
You need to pass a single element to window.getComputedStyle
So you should do this instead:
window.getComputedStyle(document.querySelector('.group-members'))
Answered By - Tanay
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.