height()和width()
作者:
琪33 | 来源:发表于
2018-04-30 08:41 被阅读0次 <title></title>
<style>
.box {
width: 100px;
height: 100px;
padding-left: 10px;
border: 10px solid #000;
background-color: pink;
}
</style>
<script src="jquery-1.11.1.js"></script>
<script>
$(function () {
//获取宽度
$("button").eq(0).click(function () {
//换个offsetHeiht不一样。只获取高度
alert($(".box").width());
})
$("button").eq(1).click(function () {
//设置宽度
$(".box").width(200);
})
//获取高度
$("button").eq(2).click(function () {
//换个offsetHeiht不一样。只获取高度
alert($(".box").height());
})
$("button").eq(3).click(function () {
//设置高度
$(".box").height(200);
})
})
</script>
</head>
<body>
<button>获取宽度</button>
<button>设置宽度</button>
<button>获取高度</button>
<button>设置高度</button>
<div class="box"></div>
</body>
本文标题:height()和width()
本文链接:https://www.haomeiwen.com/subject/bykzlftx.html
网友评论