0
Button Failure :(
Please can you help? I'm new to the community so not sure what info is usually provided on these. Basically, I have the following code on my HTML doc. When I click the "Hide text" button, nothing happens: <!DOCTYPE html> <html> <body> <p id='p1'> Writing and writing. <br> Typing and Typing. <br> Words and words. </p> <input type="button" value="Hide text" onclick="document.getElementById('p1').style.visibility="'hidden'"> <input type="button" value="Show text" onclick="document.getElementById('p1').style.visibility="visible'"> </body> </html> Thanks in advance xoxo
5 Answers
+ 10
Quotation marks must be balanced:
" - invalid
"valid" - valid
"valid' - invalid
"invalid"' - invalid...
single-quotes (') can be placed inside double-quotes (") and reverse but they also must "close" eachother...
+ 9
<!DOCTYPE html>
<html>
<body>
<p id='p1'>
Writing and writing.
<br> Typing and Typing.
<br> Words and words.
</p>
<input type="button" value="Hide text"
onclick="document.getElementById('p1').style.visibility='hidden'">
<input type="button" value="Show text"
onclick="document.getElementById('p1').style.visibility='visible'">
</body>
<html>
<!-- mind the quotes!! -->
+ 2
Thank you!
I swear I looked through that code a hundred times making sure all the quotation marks "close" each other.
This is the first time i've successfully incorporated js code into my html :)
<!DOCTYPE html>
<html>
<body>
<p id='p1'>
Writing and writing.
<br> Typing and Typing.
<br> Words and words.
</p>
<input type="button" value="Hide text"
onclick="document.getElementById('p1').style.visibility='hidden'">
<input type="button" value="Show text"
onclick="document.getElementById('p1').style.visibility='visible'">
</body>
</html>
+ 1
0
I'm sorry, i'm still not getting it :(
I'm super new to this