
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the role of scrollX property in JavaScript?
The scrollX property in JavaScript works the same as pageXoffset property. If you want to get the pixels the document scrolled to from the upper left corner of the window, then use the scrollX property for horizontal pixels.
Example
You can try to run the following code to learn how to work with scrollX property in JavaScript.
<!DOCTYPE html> <html> <head> <style> div { background-color: yellow; height: 1500px; width: 1500px; } </style> </head> <body> <script> function scrollFunc() { window.scrollBy(200, 200); alert("Horizontal: " + window.scrollX); } </script> <button onclick = "scrollFunc()" style = "position:fixed;">Scroll</button> <br><br><br> <div> </div> </body> </html>
- Related Questions & Answers
- What is the role of pageXOffset property in JavaScript?
- What is the role of scrollY property in JavaScript?
- What is the role of global RegExp property in JavaScript?
- What is the role of source RegExp property in JavaScript?
- What is the role of lastIndex RegExp property in JavaScript?
- What is the role of pageYOffset property?
- What is the role of ignoring Case RegExp property in JavaScript?
- What is the role of Keyboard Event shiftKey Property in JavaScript?
- What is the role of Keyboard Event ctrlKey Property in JavaScript?
- What is the role of Keyboard Event altKey Property in JavaScript?
- What is the role of clearTimeout() function in JavaScript?
- What is the role of throw statement in JavaScript?
- What is the role of filter() method in JavaScript?
- What is the role of Navigator object in JavaScript?
- What is the role of parseFloat() method in JavaScript?
Advertisements