简体   繁体   中英

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

This is my js script. It only creates an anchor tag with text rather than a bulma button.

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);
})

The problem is in your syntax.

This is the correct way to add a class to an element with Javascript:

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

.button should be wrapped in a.control container.

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

Are Your <a> is in container with .control class?

Bulma Documentation

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM