+ 1
How to let two functions work with one button/onclick
this is the example code, how can i 1. refer to the "start function" or 2. let two functions happen with one onclick <!DOCTYPEhtml> <html> <head> <script>ecmascript6+jquery</script> </head> <body> <h1 onclick="action1"> <script> function action1(){ //function 1 } function action2(){ //function 2 } </script> </body> </html> how to let function 1 happen before 2
8 Answers
+ 2
embed both functions in a function that calls both
onclick="Alpha()"
function Alpha(){
action1();
action2();
}
lol...its the same as ćļ¼Øļ¼”ļ¼°ļ¼°ļ¼¹ ļ¼“ļ¼Æ ļ¼Øļ¼„ļ¼¬ļ¼°ć to helps solution ,just more tidy
+ 2
ćļ¼Øļ¼”ļ¼°ļ¼°ļ¼¹ ļ¼“ļ¼Æ ļ¼Øļ¼„ļ¼¬ļ¼°ć well what can i sayš,i was happy to help
+ 2
$(document).ready (function(){
$('h1').click (action1);
$('h1').click (action2);
});
The only problem is this will put the action on all h1 tags so use an id instead or use better selector.
if you want to know more about how this works let me know.
0
Thats not nice, because i have to do it 64 times and action 2 is very long ššš
0
but is this possible
onclick="action1()"
onclick="action2()"
function Alpha(){
action1();
action2();
}
0
because otherwise i habe to do this
onclick="clearall"
onclick="action1"
onclick="action2"
function clearall(){}
function action1(){}
function action2(){}
where you have to press clearall before all other actions
0
i know but is there not something like cmd programs called goto which refers to a function like this
:alpha
cls(clears everything)
:action1
action1
break/timeout
goto alpha
this will do action 1 and wait for an users response before clearing everything but isnt there something like goto (function) in js?