var clientHeight = $(window).height(); window.onscroll = function(){ var top = document.getElementsByClassName("bottom")[0].getBoundingClientRect().top; console.log(top); if(top < clientHeight){ $("div.go_crash").css("position", "relative");
}else{ if($("div.go_crash").css("position") == "relative"){ $("div.go_crash").css("position", "fixed");
}
}
};
document.getElementsByClassName("bottom")需要做判断的元素
$("div.go_crash") 实际需要变换位置的元素