Bouton et Javascript

Fermé
Clement_7057 Messages postés 4 Date d'inscription jeudi 21 novembre 2019 Statut Membre Dernière intervention 26 octobre 2022 - 30 déc. 2019 à 11:46
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 - 30 déc. 2019 à 12:10
Bonjour,
j'ai un projet à faire en Informatique voici le sujet :" Un bouton permet de changer aléatoirement la disposition des cartes(images) dans un tableau 3 lignes 4 colonnes."
voici mon code :
<div id="figures">
			<input type="button" value="Cliquer pour mélanger">
			<table>
				<caption>12 Grandes Figures de l'informatique</caption>
				<tr>
					<td><img src="Photos/Ada Lovelace.jpg" alt="Ada Lovelace"/></td>
					<td><img src="Photos/Mark Zuckerberg.png" alt="Mark Zuckerberg"/></td>
					<td><img src="Photos/John von neumann.jpg" alt="John Von Neumann"/></td>
					<td><img src="Photos/frances-allen.png.webp" alt="Frances Allen"/></td>
				</tr>
				<tr>
					<td><img src="Photos/Grace_Hopper.jpg" alt="Grace Hopper"/></td>
					<td><img src="Photos/shannon.jpg" alt="Claude Shannon"/></td>
					<td><img src="Photos/Alan Turing.jpg" alt="Alan Turing"/></td>
					<td><img src="Photos/Dennis ritchie.jpg" alt="Dennis Ritchie"/></td>
				</tr>
				<tr>
					<td><img src="Photos/Richard Stallman.jpg" alt="Richard Stallman"/></td>
					<td><img src="Photos/Linus Torvalds.bmp" alt="Linus Torvalds"/></td>
					<td><img src="Photos/Tim Berners Lee.png" alt="Tim Berners Lee"/></td>
					<td><img src="Photos/Margaret Hamilton.bmp" alt="Margaret Hamilton"/></td>
				</tr>
			</table>
		</div>

Premier problème, je ne sais pas comment faire pour que mon bouton fasse une action : je ne sais pas comment affecter une action à mon bouton.
Deuxième problème, je ne sais pas comment déplacer les cartes dans le tableau.
I need help.....
merci

1 réponse

jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 4 650
30 déc. 2019 à 12:10
Bonjour,

Voici pour ta première question : https://www.w3schools.com/jsref/event_onclick.asp

Pour ta seconde question, cela passera par du "radomize" javascript.
Je pense que tu trouveras des exemples de code proches de ce que tu souhaites réaliser sur internet.

0