I want to show a div when the screen is scrolled 10% or 50%, tell me how this is possible with javascript?
To show content when screen is scrolled.
Use CSS property display: none
; and display: block
; or use visibility: hidden
; and visibility: visible
;.
Choose either method depending on your requirement.
This can be done using JQuery!
<script>
$(window).scroll(function() {
if ($(window).scrollTop() >= 400) {
$("#id").css("display", "block");
} else {
$("#id").css("display", "none");
}
});
</script>
Try this.
If you still have a question about this, submit it in our Q&A community - Ask Question