mercredi 2 mai 2018

Place button iterating a list

I want to create these buttons:

<!DOCTYPE html>
<html>
<body>

<button type="button">Linear algebra    </button>
<button type="button">Calculus I    </button>
<button type="button">Basic Mechanics    </button>
<button type="button">Mechanics1    </button>
<button type="button">Mechanics2    </button>
<button type="button">Mechanics3    </button>
<button type="button">Mechanics4    </button>
<button type="button">Mechanics5    </button>

</body>
</html>

And I was wondering if there is an option to do it with a function for when the list is even longer. My idea is to create the following list:

var subjects=["Linear algebra","Calculus I","Basic Mechanics","Mechanics1","Mechanics2","Mechanics3","Mechanics4","Mechanics4"]

And iterate it with a for loop and then create the button with the result of every element in the list. Is this possible?




Aucun commentaire:

Enregistrer un commentaire