0
How to change my HTML text to text I entered in prompt? I have written the JavaScript but I do not get it.
Profile page https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app
34 Answers
+ 3
kaspars kaspars hi,
In the Html you changed your class for an id but still asks for ElementsByClassName in js
Here you'll have to use Element ById.
And the way you did it first should be able to work,maybe the problem was that when you get your elements by class name, it is stored within an array, so if you refer to one of the element of that array you have to use its index.(even if there is only one in your previous code).
+ 2
Thanks that fixed the problem
+ 2
I don't know if it will solve the problem but from what I see in your Html:
*You made a mistake when you close your div class="drop-down" (it's closed to soon, before the </ul> tag.
*Your div class="drop-down" is not a child of your div class="profile-contact" , as in your CSS it s the way you'd like to use it...
To be confirmed.
+ 2
What Abhay did is that he added an eventListener in your Html (onclick="sd()").
When your button is clicked, it calls the sd() function which is coded in the js file.
The function check the state of your drop-down thanks to a flag.
If it is 0, it order to display it block and the flag now get a new value of 1
Next time you click, the function will use the other part of instruction where flag is 1, then order the display to none and give the flag a value of 0.
And so on...
Here the display from your CSS is handled by that js function.
But for sure, you can have your drop-down menu only with CSS.
+ 2
For any help
Just tell me
I will always ready to help my fellow Sololearn friends
+ 1
If you give class remember that unlike id, several elements could have same classes, so when you getElementsByClassName it will store all of them in an array, even if there is only one element with that class name.
So to access/refer to it use its index(here [0])
0
Why it have to be button and why and ID not class?
0
Why it don't work for me, pls tell me what you did
https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app
0
Can you tell me why my drop-down menu do not work?
https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app
0
Your drop down fix
https://code.sololearn.com/WsRLqcuVXgF7/?ref=app
0
Can you tell me what you did??
0
I fixed the div but I don't understand what you did to get drop down working
0
How do n do the same in only CSS?
0
Why I have error omg I try 3 days to make this
https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app
0
That s not simple at all :O
0
Why my drop-down don't work? I tried everything...
https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app
0
Two mistakes:
First , same as previous one , you gave class in html but get element by Id in js.
Second, don't give same name to your variable where you stock your element and to your function.
0
I fixed both, still ain't working
error line 21
https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app