jQuery——尺寸位置

获取宽:$(".box").width()

设置宽:$(".box").width(200)

获取高:$(".box").height()

设置高:$(".box").height(200)

<script>
    $(function () {
        //距离页面最顶端或者最左侧的距离和有没有定位没有关系
        $("button").eq(0).click(function () {
            alert($(".box2").offset().top);
        })

        //距离页面最顶端或者最左侧的距离和有没有定位没有关系
        $("button").eq(1).click(function () {
            $(".box2").offset({"left": 1000, "top": 1000});
        })

        //距离父系盒子中带有定位的盒子的距离(获取的就是定位值,和margin/padding无关)
        $("button").eq(2).click(function () {
            alert($(".box2").position().top);
        })

        //距离父系盒子中带有定位的盒子的距离(获取的就是定位值,和margin/padding无关)
        $("button").eq(3).click(function () {
            $(".box2").position().top = "100px";
        })

        //获取被选取的头部
        $("button").eq(4).click(function () {
            alert($(window).scrollTop());
        })

        //获取被选取的头部
        $("button").eq(5).click(function () {
            $(window).scrollTop(100);
        })

    })
</script>

总结:很鸡肋,一般设置可通过css()方法设置