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

9th Apr 2020, 8:05 AM
kaspars kaspars
kaspars kaspars - avatar
34 odpowiedzi
9th Apr 2020, 8:17 AM
Abhay
Abhay - avatar
+ 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).
9th Apr 2020, 9:42 AM
EmmanueLZ.
EmmanueLZ. - avatar
+ 2
Thanks that fixed the problem
9th Apr 2020, 10:35 AM
kaspars kaspars
kaspars kaspars - avatar
+ 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.
9th Apr 2020, 1:31 PM
EmmanueLZ.
EmmanueLZ. - avatar
+ 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.
9th Apr 2020, 1:54 PM
EmmanueLZ.
EmmanueLZ. - avatar
+ 2
For any help Just tell me I will always ready to help my fellow Sololearn friends
9th Apr 2020, 2:02 PM
Abhay
Abhay - avatar
+ 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])
9th Apr 2020, 2:56 PM
EmmanueLZ.
EmmanueLZ. - avatar
0
Why it have to be button and why and ID not class?
9th Apr 2020, 9:09 AM
kaspars kaspars
kaspars kaspars - avatar
0
Why it don't work for me, pls tell me what you did https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app
9th Apr 2020, 9:23 AM
kaspars kaspars
kaspars kaspars - avatar
0
Can you tell me why my drop-down menu do not work? https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app
9th Apr 2020, 1:15 PM
kaspars kaspars
kaspars kaspars - avatar
9th Apr 2020, 1:28 PM
Abhay
Abhay - avatar
0
Can you tell me what you did??
9th Apr 2020, 1:30 PM
kaspars kaspars
kaspars kaspars - avatar
0
I fixed the div but I don't understand what you did to get drop down working
9th Apr 2020, 1:32 PM
kaspars kaspars
kaspars kaspars - avatar
0
How do n do the same in only CSS?
9th Apr 2020, 2:05 PM
kaspars kaspars
kaspars kaspars - avatar
0
Why I have error omg I try 3 days to make this https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app
9th Apr 2020, 2:14 PM
kaspars kaspars
kaspars kaspars - avatar
0
That s not simple at all :O
9th Apr 2020, 2:23 PM
kaspars kaspars
kaspars kaspars - avatar
0
Why my drop-down don't work? I tried everything... https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app
9th Apr 2020, 2:28 PM
kaspars kaspars
kaspars kaspars - avatar
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.
9th Apr 2020, 2:33 PM
EmmanueLZ.
EmmanueLZ. - avatar
0
I fixed both, still ain't working error line 21 https://code.sololearn.com/W1l1Lrl7sYKu/?ref=app
9th Apr 2020, 2:48 PM
kaspars kaspars
kaspars kaspars - avatar