+ 2

Why is my onclick setinterval not working

My onclick is inside a if statement and am trying to check which button is been clicked so that I can activate the on click functions https://code.sololearn.com/WqW08Lzyv4n3/?ref=app

10th Feb 2022, 6:51 AM
D Doyen
D Doyen - avatar
18 Respostas
+ 4
D Doyen 1 - single equal (=) is used for assign value to a variable 2 - double equal (==) is used to compare value 3 - how do you check button is clicked or not if there is no click event added? 4 - don't write custom function inside onload function. 5 - two is a list of nodes so you cannot add event like two.onclick 6 - first check if click event not occurs on button then add event Do you want like this? https://code.sololearn.com/WZObBA46bNec/?ref=app
10th Feb 2022, 7:50 AM
AĶ¢J
AĶ¢J - avatar
+ 3
Make sure your if statement contains '==' and not '='
10th Feb 2022, 7:13 AM
cadbrooke
cadbrooke - avatar
+ 3
D Doyen, What's up? please explain clearly what you want this code do. For example, why you put event handler in a conditional ...
10th Feb 2022, 9:06 AM
Ipang
+ 2
Ipang I have 2 text in quotes One name arry and another arry1 And I have three buttons if I click button with index 0 I want arry to be written inside the button with index 0 And when the button with index 1 is clicked I want arry1 to be written inside the button with index 1 In form of typing animation Thanks in advance
10th Feb 2022, 9:15 AM
D Doyen
D Doyen - avatar
+ 2
D Doyen, I modified your code and added some comments to explain. One thing I can't help you with, is the inconsistent position of button once their text was modified. https://code.sololearn.com/WExTIz7A4a9H/?ref=app
10th Feb 2022, 1:04 PM
Ipang
+ 2
Ipang Thanks for the fix it works perfectly But can Pls tell me where you learnt everything you used because I have not heard of set attribute and the likes Thanks in advance
10th Feb 2022, 1:21 PM
D Doyen
D Doyen - avatar
+ 2
But thanks for the fix it was fantabulous mind blowing And Pls tell me how you learn every thing I mean links to website where you learnt those things
10th Feb 2022, 1:24 PM
D Doyen
D Doyen - avatar
+ 2
And for the position changing I can fixed that I encountered it before
10th Feb 2022, 1:25 PM
D Doyen
D Doyen - avatar
+ 2
D Doyen, No problem About setAttribute etc. I get more from what's available in the official course from reading community members' codes. When I don't understand what something is, I either ask the code author, a friend, or search the net ... Answers to questions in Q&A Discuss also teach me indirectly ...
10th Feb 2022, 1:31 PM
Ipang
+ 2
D Doyen, I look forward to seeing your code be more properly indented in the future. Indentation improves code readabilty and it also helps when debugging codes šŸ‘
10th Feb 2022, 1:34 PM
Ipang
+ 2
D Doyen, Sorry I don't really have a particular source of learning so I don't know what to suggest. I was one of those guys who just pick things up as I go, from various places. But w3schools, MDN and javascript.info might worth a visit.
10th Feb 2022, 1:50 PM
Ipang
+ 2
Ipang thanks
10th Feb 2022, 5:07 PM
D Doyen
D Doyen - avatar
10th Feb 2022, 8:55 AM
D Doyen
D Doyen - avatar
+ 1
AĶ¢J Pls the code you wrote is not working on my device My device does not support advance javascript
10th Feb 2022, 9:00 AM
D Doyen
D Doyen - avatar
+ 1
AĶ¢J Pls I want a typing animation in each button that is clicked And I want each button to have it own text
10th Feb 2022, 9:02 AM
D Doyen
D Doyen - avatar
+ 1
My own fix was this though it doesn't work properly var arry = ("sola is my ghfffffejdj djdjdjdjjjj jjjjjjjjjebeuehbe wwm mmwo djdjjdjtfd hjsjs ussjsj name") var arry1 =("def") var w = 0; var two = document.getElementsByTagName("img"); function run(j,arry){ function type(){ var four = document.getElementsByClassName("four"); var two = document.getElementsByTagName("img"); four[j].innerHTML += arry.charAt (w) four[1].style.visibility="visible" w++ } setInterval (type,100) } two [0].onclick=function(){ run(0,arry)} two[1].onclick =function(){ run(1,arry1)}
10th Feb 2022, 1:22 PM
D Doyen
D Doyen - avatar
0
Ipang links
10th Feb 2022, 1:27 PM
D Doyen
D Doyen - avatar
0
Hello can someone help me out with a doubt
12th Feb 2022, 2:33 AM
Jeetain Suri
Jeetain Suri - avatar