How do i make the button to show on click and then hide on second click | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do i make the button to show on click and then hide on second click

i made my text to show on click but i want to make it hide when u click it a second time https://code.sololearn.com/W0o6T593EV8L/?ref=app

9th Jan 2018, 6:47 PM
BG Simeon Simeonov
BG Simeon Simeonov - avatar
13 Answers
+ 4
Here is my solution, hope it helps, what it does is this: it created a boolean called "open" and when you click the button, it checks whether open is true or false, and based on that, it changes the boolean and you can input the code within the if statement https://code.sololearn.com/WpX2byq78S5Z/?ref=app
9th Jan 2018, 6:57 PM
wout werkman
wout werkman - avatar
+ 4
don't use CSS that much, but I think it's just background { width:100%; height:100%; }
9th Jan 2018, 7:13 PM
wout werkman
wout werkman - avatar
+ 3
Благодаря, ще го пробвам!
9th Jan 2018, 10:58 PM
BG Simeon Simeonov
BG Simeon Simeonov - avatar
+ 3
Точно това исках да постигна. Може ли само да ми обясните как работи, за да го разбера.
10th Jan 2018, 2:33 PM
BG Simeon Simeonov
BG Simeon Simeonov - avatar
9th Jan 2018, 9:03 PM
Boris Batinkov
Boris Batinkov - avatar
+ 2
Не знам как става по най-добрия начин. Помня, че веднъж пробвах със снимка, която не се побира в екрана (по-широка), освен така: CSS: background-size: 100% 100%; margin: auto; width: 50%; Което я набута в екрана, обаче естествено беше леко смачкана. В обратния случай (ако е по-малка), най-вероятно ще я разтегли по горния метод. Иначе за показването/скриването на информацията импровизирах. Не ми е най-силната страна Web-а :)
9th Jan 2018, 11:21 PM
Boris Batinkov
Boris Batinkov - avatar
+ 2
Is it works now? / Така става ли? https://code.sololearn.com/Wjw8raiGJ6jl/?ref=app Обаче отворено/затвореното състояние в условните конструкции е обърнато. Т.е при затворено състояние показва информацията.
10th Jan 2018, 2:29 PM
Boris Batinkov
Boris Batinkov - avatar
+ 2
1. Вкарах състоянието на всички бутони в array, за да не пиша отделни променливи за всички бутони. 0 => false != 0 => true В началото всички бутони са 0 (затворени) 2. Когато се отвори някой бутон, другите трябва да се затварят. Например: open[0] = 1; // button 1 is open open[1] = 0; // button 2 is closed open[2] = 0; // button 3 is closed
10th Jan 2018, 2:52 PM
Boris Batinkov
Boris Batinkov - avatar
+ 1
ohh nvm... i just saw the alert command
9th Jan 2018, 7:09 PM
BG Simeon Simeonov
BG Simeon Simeonov - avatar
+ 1
Yes it is. I am very thankful for your help!!!
9th Jan 2018, 7:16 PM
BG Simeon Simeonov
BG Simeon Simeonov - avatar
+ 1
All worked great, but how do i make button 2 to replace the content of button 1 on click but then if i click it again it show the <p>. (Значи когато отворя бутон1, за да отвора бутон2 или 3 трябва да кликна два пъти върху него. Въпросът ми е. Как да го направя така че когато се натисне различен от отворения бутон да се смени контента с един клик, но когато кликна върху вече отворения бутон да се затвори и съответно да се покаже "<p> id="t1"The Germ.......<\p>"? Всякаква помощ ще е от полза. https://code.sololearn.com/WRs43gPepNty/?ref=app
10th Jan 2018, 1:43 PM
BG Simeon Simeonov
BG Simeon Simeonov - avatar
0
Ok i fixed it. Is there any way to remove the pop ups? Thank you btw! https://code.sololearn.com/Wp7K8IC1DzrY/?ref=app
9th Jan 2018, 7:08 PM
BG Simeon Simeonov
BG Simeon Simeonov - avatar
0
and one more question. How to make the img fit the hole background
9th Jan 2018, 7:09 PM
BG Simeon Simeonov
BG Simeon Simeonov - avatar