+ 1
Someone to help me please!?
There are four buttons that have value 1, 2, 3 and 4. If I click on 1 I want a message that alert 1. When I click on 2 the message will alert 2 so on for each button. I do not want the code to be too long by doing 4 different functions for each event click. So I will use a single function alert (); for 4 click events What needs to be done: 1-) Do I have to pass a parameter to the function alert ()? How to do this with the events? 2-) Do I have to add other click events to modify a defined variable in order to select the alert message? 3-)Do I need class or objects? I want tips to be more effective. Thank you!
5 Respuestas
+ 3
1. yes just pass the string, you can add an event by adding onclick attribute in your html element
2. not really, but its depend on how you implement it.
3. no
+ 3
This is what Taste means
https://code.sololearn.com/W0ljg9nielWs/?ref=app
+ 2
Thank you Taste. How to to that (option1)?
+ 2
Thank you Gordon