使用 jquery 增加或减少偏移量



我有一个弹出窗口。我想在弹出窗口中有两个加号和减号按钮。单击时的两个按钮应该能够更改弹出窗口的偏移量。我的问题可能不成熟,但我是 jquery 的新手,所以我无法处理这种情况。如何使按钮工作。

 <div class="button" id="show">
    <button type="button">Show popup</button>
</div>

<div class="container-popup" id="container-popup">
<div>
    <button type="button" id="plus">Increase</button>
    <button type="button" id="minus">Decrease</button>
</div>
    <div class="pop-up" id="pop-up">
        <div class="circleBase type2" id="close">x</div>
        <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.</p>
    <p>Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
    <p>Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
    </div>
</div>

这是我的JSFIDDLE:

$("#plus").click(function(){
        var x=$("#pop-up").offset();
        $("#pop-up").offset({top : x.top + 5, left : x.left + 5});      
});

设置弹出元素的偏移量。检查小提琴

最新更新