Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I would like to put this : (im french)
JavaScript
window.onload=function(){
		const facileBtn=document.getElementById("boutonF");
		const moyenBtn=document.getElementById("boutonM");
		const difficileBtn=document.getElementById("boutonD");

		function changeEnFacile(){
			console.log("ca marche")
			document.getElementById("calcul").innerHTML="c'est facile";
		}

		function changeEnMoyen(){
			console.log("ca marche")
			document.getElementById("calcul").innerHTML="c'est moyen";
		}

		function changeEnDifficile(){
			console.log("ca marche")
			document.getElementById("calcul").innerHTML="c'est difficile";
		}



		facileBtn.addEventListener('click',changeEnFacile);
		moyenBtn.addEventListener('click',changeEnMoyen);
		difficileBtn.addEventListener('click',changeEnDifficile);
	}


in a Javascript file and then put
HTML
<script src="file.js">


What I have tried:

I have to precise that the program works in the HTML "script" tag. But it doesn't work... suggest ?
Posted
Updated 8-Mar-23 20:37pm
v2
Comments
Richard MacCutchan 8-Mar-23 10:59am    
Firstly that is Javscript, not Java. Secondly, we have no idea what is meant by "it doesn't work". Please use the Improve question link above, and add complete details of what is not working.

1 solution

Hello !


as the script tag is 'duet', for your need :

<script src="file.js"></script>

// you can write it between 'head' tags, or in 'body' tag
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900