<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
header{
width: 100%;
position: fixed;
top: 0;
}
.up{
height: 55px;
background-color: darkgreen;
cursor: pointer;
}
.low{
height: 60px;
background-color: darkgray;
}
.ad{
height: 340px;
background-color: #3a945b;
margin-top: 115px;
}
article{
height: 1000px;
background-color: orange;
}
footer
{
height: 320px;
background-color: #1a1a1a;
}
</style>
<script src="src/javascript/jquery-3.2.1.js"></script>
<script>
$(function () {
var w = $('body').width();
$('.up').click(function () {
if(w>'1280px'){
$('.low').animate({marginTop:200})
}else{
$('.low').animate({marginTop:50})
}
});
});
</script>
</head>
<body>
<header>
<section class="up"></section>
<section class="low"></section>
</header>
<div class="ad"></div>
<article></article>
<footer></footer>
</body>
</html>
if 没作用,else可以?
改成