How to focus on particular part of a web page by using javascript events?
Let's say I clicked a button and it will scroll down or scroll up to a particular portion a page.
Focus on a particular portion of a web page using javascript
-
- Posts:107
Focus on a particular portion of a web page using javascript
MarPlo
Posts:186
Hi,
To scroll to a specified element, use the element.scrollIntoView() method (this method scrolls the current element into the visible area of the browser window):
- To scroll to a pixel location, you can use the scrollTop property
To scroll to a specified element, use the element.scrollIntoView() method (this method scrolls the current element into the visible area of the browser window):
Code: Select all
<script>
var element = document.getElementById('elm_id');
element.scrollIntoView();
</script>
Code: Select all
<script>
document.body.scrollTop = 800; // 800 pixels from top of the page
</script>
Similar Topics
- Display message to every minute in Javascript
JavaScript - jQuery - Ajax First post
Hello,Last post
On eatch minute from the current hour I wanna have an message
I can not find out how to complete
I hope to get something like this (code...
If you only want to display a message to every minute, just use the setInterval() function. It calls a function repeatedly, over and over again, at... - Hour and Minutes togheter in Javascript
JavaScript - jQuery - Ajax First post
Dear Coursesweb I can not find out how to add the hours + minutes togheter.Last post
<SCRIPT LANGUAGE= JavaScript >
day = new Date()
hr =...
See and use the following example:
<script>
var day = new Date();
let hr = day.getHours();
let mn = day.getMinutes();
let se =...