Is it possible to create bootstrap button dynamically? I have a textfile that have a list of items where I will make use of javascript to create an array with. That is where I would like to create bootstrap buttons dynamically with those items being the text within each button. If there is 10 items in the textfile, there would be 10 buttons created. Can someone tell me how can it be done or point me to some tutorial about it.
EDIT(Creation is possible now but not code for checking if buttons is created):
createButtons():
$(function() {
$.ajax({
url : 'http://localhost:8080/SSAD/type.txt',
dataType : "text",
success : function (filecontent) {
var lines=filecontent.split('\n');
$.each(lines, function() {
if (this!='') {
var word = this;
word = word.toLowerCase().replace(/(?:_| |\b)(\w)/g, function(str, p1) { return p1.toUpperCase();});
if ($('button:contains("'+word+'")').length==0) {
var button='<button type="button" class="btn btn-block btn-inverse active" data-toggle="button tooltip" title="Click this to enable/disable viewing of'+this+'" onclick="toggleVisibility('+"'"+this+"'"+')">'+word+'</button>';
$(".crisisButtons").append(button);
}
}
});
}
});
});
HTML:
<button type="button" class="btn btn-block btn-inverse" onclick="createButtons">Click me!</button>
<div class="crisisButtons"></div>
