2013-10-30 72 views
0

我有一個彈出窗口。我想要兩個按鈕加上和減去彈出。點擊兩個按鈕應該能夠改變彈出窗口的偏移量。我的問題可能不成熟,但我是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

回答

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

設置了彈出元件空間偏移。檢查fiddle

+0

謝謝..它的工作原理。 – Sami

+0

不客氣:) – Surender