2013-10-07 147 views
-2

在這裏,我有我打開模態窗口代碼:添加股利按鈕其它ID的div點擊

contentStr += '<div>Lorem Ispum</div><button>Add to timeline</button></div>'; 

      $(contentStr).dialog({ 
       modal:true 
      }); 

現在我想,當我點擊button添加到時間線上添加:'<div id="new">place.name</div>'div ID bottom但留有餘量var "N"

我怎麼能用jQuery來做到這一點?

+0

提出了一個小提琴請。或者至少在這裏轉儲你的代碼 –

+0

http://jsbin.com/UNuRexA/28 –

+0

所以首先點擊提交,然後點擊地圖上的標記,然後點擊按鈕 –

回答

0

假設你的意思是你有一個var N somwhere你想將它應用到保證金左:

$('button').click(function(){ 
    $('#bottom').append($('<div id="new">place.name</div>').css('marginLeft',N+'px')); 
}); 

提醒的一些話,這jQuery是非常基本的,接下來的時間做一些研究,請與表演在這裏你發現了什麼以及你在哪裏掙扎。

+0

好的,但這必須在按鈕點擊工作 –

+0

@jsdna rofl抱歉,漫長的一天...固定 – TecHunter

-1
<style> 
.marginLeft { 
    margin-left: Npx; 
} 
</style> 
<script> 
$.('button').click(function(){ 
    $('div#buttom').html($('div#buttom').html+'<div class="marginLeft" id="new">place.name</div>'); 
}); 
<script> 
+0

我可能有利於在樣式標記中定義樣式而不是混合它與上面的代碼。 – user2793390

+0

不工作....... –