I am a beginner programmer which have appended a list of buttons into a div
. However, the list of buttons are side by side as shown below here,
I want a line break after each button so they will be on top of each other instead. My codes to append using .setattribute()
are as shown below,
<script>
var arr = [{"userid": "jim", "title":"help"}, {"userid": "pim", "title":"hello"}]
var i;
$("enquirieswall").empty();
for (i = 0; i < arr.length; i++) {
var a = document.createElement("button");
a.setAttribute("href", "#");
//a.textContent = arr[i].title;
a.innerHTML = arr[i].title.toString();
a.setAttribute("class", "btn");
a.setAttribute("type", "button");
a.setAttribute("onclick", "window.location='enquiriesdetails.php?enid=" + arr[i].enid + "&userid=" +arr[i].userid +"'");
$("#enquirieswall").append(a);
}
</script>
<div id="enquirieswall"></div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.