+ 2
Why does it take 2 clicks? --
So I'm just experimenting Javascript, and I'm not sure why I have to click twice to make the content of a div appear. Do you think you can make it to where you only ha move to click once to View/hide content? If ues do, let me know in the comments. https://code.sololearn.com/Wq422ZTAGZbS/?ref=app
4 Réponses
+ 1
Ginfio yes there is but you don't need the === here
== is equals to
=== equals to and of same type
+ 3
Ginfio the style property for html dom objects get/set the INLINE style property and nothing more... This mean than if you setted a css prop using css declaration in a stylesheet, it will not result using el.style.prop... For your problem you can solve in 2 ways:
1) Set to div "content" the initial inline style property (add style="display:none" into html element code)
2) Use the method window.getComputedStyle(x); than return a style object than browser has computed for your element (no matter how you setted the style, it will return the current setted one)
+ 2
There is nothing wrong with your code, but the order is wrong, I fixed it
https://code.sololearn.com/W7IMQoJ6y82U/?ref=app
0
ok, I got one more thing to add to this question: Why do we put "===" (3 equal signs) on the if statement? Is there any difference between 2 equal signs("==") and three equal signs("===") ?