Problem with details with JavaScript | Sololearn: Learn to code for FREE!

+1

Problem with details with JavaScript

Hello, in this code i have add some JS to hidden the rest of <details> in the page, when click on details the other details are hidden and if click again the rest of details is showed. the problem is after the first click if click in other point of details( for exapmle in the text) the function onclick associated run but the details remain open. i have tried to risolve to add: document.getElementId("details").open= 'true'; document.getElementId("details").open= 'false'; but don't work thanks to those who want to help me https://code.sololearn.com/WLcO7JBeMgHw/#

5/21/2020 4:35:37 PM

Alessio Farroni

16 Answers

New Answer

+4

See this code :)) https://code.sololearn.com/WltPavNklhI4/?ref=app Click on those titles to open the details :))

+3

Alessio Farroni Base on what you wanted your code to do, I refactored your script. https://code.sololearn.com/WlUdjbDZoyUJ/#html

+1

I made everything by own https://code.sololearn.com/WMoVWO5g84oh/?ref=app

+1

David D. I solved After have see your work, thank's ☺️

+1

It is ok, I did it in few minutes, now I started with another code - quiz app

+1

ODLNT thank you, very nice code. Is very clean and clear. I'll study It😉

0

Hey, sorry I m saying that but delete all your code and start from scratch

0

Why dont you add another button on the page or part which is opening after clicking button to close it .

0

🇮🇳 AYUSH.ks 🇮🇳 because the problem will still remain, if clicking on the text, details does'nt close

0

David D. Thank you, I was thinking to throw away my computer 😆 ...however I still think where the problem is and how to solve it

0

I am not good at web making but I can make good script for that

0

Hey what exactly should it do?

0

David D. When its clicked on the text(<p>) of the opened details it has to be closed so that the user has the oportunity to open another details Thank you so much for helping☺️

0

thank you all for your help I solved it by assigning onclick to <summary> instead of <div> or <details>

0

I edited a bit you can use mine if you want

0

Ohh, 😕 I did that for nothing useless