2014-10-29 69 views
-2

時不顯示彈出我有以下我的HTML文件 哪個編輯按鈕點擊後,打開一個彈出,一切工作正常爲什麼點擊首次

<div class="col3 pull-left"> 
<a class="btn mini black editscreenT1" title="Edit FOR T1" data-toggle="modal" href="#editrespon_popup" ><i class="icon-edit"></i></a> 
</div> 

<div id="editrespon_popup" class="modal hide fade" tabindex="-1" data-width="360" style="width:350px;"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> 
      <h3>Edit Name</h3> 
     </div> 
    </div> 

但當我試圖動態做到這一點如圖所示,這是不開放彈出式窗口,有在瀏覽器控制檯沒有errorrs

$(document).on("click", ".editscreenT1", function (e) 
{ 
var html = ' <div id="editrespon_popup" class="modal hide fade" tabindex="-1" data-width="360" style="width:350px;">\ 
     <div class="modal-header">\ 
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>\ 
      <h3>Edit Name</h3>\ 
     </div>\ 
    </div>'; 


$(".editscreenT1").attr("href",html); 

    }); 

爲什麼點擊了首次在編輯按鈕時,不顯示彈出

從起正在對編輯按鈕顯示彈出第二次點擊

+0

創建jsfidddl – 2014-10-29 12:29:43

+0

這裏我沒有得到任何彈出http://jsfiddle.net/kxenmycq/ – 2014-10-29 12:30:30

+0

因爲首先點擊有針對」 .editscreent1' 沒有href屬性。當它被點擊後,href屬性有一些讓彈出窗口彈出的值。 – Jinandra 2014-10-29 12:37:22

回答

1

您試圖錨標記的href屬性設置爲DIV結構。

取而代之的是,將彈出的DIV附加到html body或其他您希望的選擇器,並將HREF屬性設置爲錨點的DIV選擇器。

請嘗試了這一點,

$(document).on("click", ".editscreenT1", function (e){ 
var html = ' <div id="editrespon_popup" class="modal hide fade" tabindex="-1" data-width="360" style="width:350px;">\ 
     <div class="modal-header">\ 
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>\ 
      <h3>Edit Name</h3>\ 
     </div>\ 
    </div>'; 
$("body").append(html); 

$(".editscreenT1").attr("href","#editrespon_popup"); 
});