Sticky div on Scroll JavaScript With Example

This blog is all bout sticky div on scroll javascript with an example, in this blog, you will get how to stick a div when scrolling the browser to the top of the browser.



In the below example you will see the search bar of the HTML page is sticked at top after scroll top.

sticky div on scroll javascript with example

Set-1

Add the extra DIV   <div id="boxHere"></div>
and add   id = "boxThis" this code in which div has to stick at the top.



Set-2

Add a small line of CSS below

 

 



Set-3

Add a small piece JS of code in the Footer section

 

Now it will work.



Still, if you want this code, Please click here to download it.

 



Tags: