Get the scroll top and left position of an element using jquery

  • جي كويري

Get the scroll top and left position of an element using jquery

الأجوبة

HTML Code:

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  <meta charset="utf-8">
  <title>Get the scroll top and left position of an element</title>
  <style>
   p {
    margin-top:20px;
    margin-left: 10px;
    padding: 5px;
    border: 2px solid #666;
  }
  </style>
</head>
<body>
  <p> </p>
</body>
</html>

JavaScript Code :

console.log("Scroll left, top position  of the  Paragraph are:"+$("p").scrollLeft()+',' +$("p").scrollTop());
هل كان المحتوى مفيد؟

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...