簡體   English   中英

如何<a>使用 JS</a>創建 Bulma 按鈕元素而不是 HTML

[英]How to create Bulma button element rather than HTML <a>, using JS

這是我的 js 腳本。 它只創建一個帶有文本的錨標簽,而不是一個 bulma 按鈕。

elementos.forEach(function(value,index){
    var button = document.createElement("a");
    button.class = "button is-primary is-rounded";
    button.innerHTML = "Element " + (index +1)+ ": " + value
    container.appendChild(button);
})

問題出在你的語法上。

這是將 class 添加到具有 Javascript 的元素的正確方法:

 button.classList.add("button is-primary is-rounded")

.button 應該被包裹在 a.control 容器中。

<div class="control">
    <button class="button is-link">Submit</button>
</div>

您的<a>是否在帶有.control class 的容器中?

布爾瑪文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM