In a web page, there is a div element known as 'div1'. The desired functionality is for a button to appear on the navigation bar once 'div1' has been scrolled completely. Otherwise, the button should stay hidden. An attempt was made to achieve this using the following code:
$(function(){
$("#b1").hide();
var height1 = $("#d1").height();
var height2 = $("#d2").height();
var eventPosition = height1 + height2;
$(window).scroll(function{
if(window.screenY >= eventPosition) {
fireEvent();
} else {
fireEvent1();
}
});
fireEvent() {
$("#b1").show();
}
fireEvent1() {
$("#b1").hide();
}
});