Hi,
I have a div that appears as you scroll to the bottom of the page and then fades out as you scroll back up. I would like to add a close button to the div which I have done and sort of works. It closes the div, but if you scroll, it appears again.
This is my code:
function toggle() {
var ele = document.getElementById("offerbox");
var text = document.getElementById("displayText");
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "show";
}
else {
ele.style.display = "block";
text.innerHTML = "hide";
}
}
$(document).ready(function(){
$(window).scroll(function(){
// get the height of #wrap
var h = $('#wrapper').height();
var y = $(window).scrollTop();
if( y > (h*.25) && y < (h*.75) ){
// if we are show keyboardTips
$("#offerbox").fadeIn("1000");
} else {
$('#offerbox').fadeOut('1000');
}
});
})
Any ideas whats wrong?
Thanks