我使用Bootstrap和jquery爲我的網站,我有一個問題。 當我創建動態的元素,我沒有相同的渲染我的「靜態」的元素,這是我的HTML元素:我沒有與動態創建的元素相同的呈現 - jQuery - 引導
<div class="row" style="margin-bottom: 10px;">
<div class="col-xs-4 col-sm-2">
<button type="button" class="action btn btn-default">
<span class="glyphicon glyphicon-cog"></span>
</button>
<button type="button" class="action btn btn-default">
<span class="glyphicon glyphicon-remove"></span>
</button>
</div>
</div>
這就是渲染,我添加按鈕點擊:
我不知道爲什麼渲染是這樣的,因爲我已經把同樣的html元素在我的廣告d按鈕listenner:
$("#btnAddBuild").click(function(){
var htmlContent = "<div class='row' style='margin-bottom: 10px;'>" +
"<div class='col-xs-4 col-sm-2'>" +
"<button type='button' class='action btn btn-default'><span class='glyphicon glyphicon-cog'></span></button>" +
"<button type='button' class='action btn btn-default'><span class='glyphicon glyphicon-remove'></span></button>" +
"</div>" +
"</div>"
//console.log(htmlContent);
$("#rowListBuilds").append(htmlContent);
});
由於
可以在您的代碼添加Add按鈕? – claudios
區別在於空格。由於換行符,您的原始版本在按鈕之間存在間隙。 jQuery附加版本構建爲連續字符串。最簡單的解決方法是在您構建的字符串中的按鈕之間添加一個空格。 –
你還好吧@RoryMcCrossan – KhoyaDev