File size: 863 Bytes
63ca3c7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./js/jquery-3.6.0.min.js"></script>
<style>
.box1{
width: 100px;
height: 100px;
background-color: red;
}
.box2{
background-color: green;
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
<script>
// 获取box1宽度和高度
var width = $(".box1").width();
var height = $(".box1").height();
console.log(width,height);
// 设置box2的宽度和高度 链式调用
$(".box2").width(200).height(200);
</script>
</body>
</html> |