如何使用 JS 创建 Bulma 按钮元素而不是 HTML <a>
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);
})
问题出在你的语法上。
这是 add a class to an element 和 Javascript 的正确方法:
button.classList.add("button is-primary is-rounded")
这是我的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);
})
问题出在你的语法上。
这是 add a class to an element 和 Javascript 的正确方法:
button.classList.add("button is-primary is-rounded")