更新时间:2023-02-05 21:37:05
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="jquery.js"></script>
</head>
<body>
<div style="width:100%;height:100px;position:fixed;background: red"></div>
<div style="width:100%;height:2000px;background:blue;";></div>
</div>
</body>
<script type="text/javascript">
$(document).scroll(function(){
if($(document).scrollTop() > 300)
$('div:first').css('background','white');
else
$('div:first').css('background','red');
})
</script>
</html>