Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
getBoundingClientRect() is not a function

i'm trying to get the window hight and the y rect of the element i got a message '.getBoundingClientRect() is not a function'

hint : here is the complete project so u can see my problem. i'm getting the error in the log here is my code:

var messageGetter = $('.message');
var clientH = document.documentElement.clientHeight;
var memoY = messageGetter.getBoundingClientRect().height;
alert(memoY);

$(document).scroll(function(){
  if(messageGetter.isInViewport()){
    messageGetter.fadeIn('slow').css('visibility', 'visible');
  }

})
  
    <div class="lower-container">

  <div class="message message-right">
     <p class="message-content">I agree that your message is awesome!</p>
     <div class="message-timestamp-right">SMS 13:37</div>
     <div class="ball-right"></div>
     </div>

     <div class="message message-left">
        <p class="message-content">I agree that your message is awesome!</p>
        <div class="message-timestamp-right">SMS 13:37</div>
        <div class="ball-left"></div>
        </div>

       <div class="message message-right">
          <p class="message-content">gggg</p>
          <div class="message-timestamp-right">SMS 13:37</div>
          <div class="ball-right"></div>
       </div>

       <div class="message message-left">
          <p class="message-content">I agree that your message is awesome!</p>
          <div class="message-timestamp-right">SMS 13:37</div>
          <div class="ball-left"></div>
          </div>
    </div>





    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="index.js" charset="utf-8"></script>
  </body>
</html>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe this is happening because under the jQuery hood $(".message") is calling document.querySelectorAll('.message') which returns an array of the elements, rather than an element itself, therefore when you try to call .getBoundingClientRect() it's not a function because you're not directly accessing any element.

Try doing

$(".message")[0].getBoundingClientRect()

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!