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

11th Apr 2018, 7:41 PM
Rachael
5 Réponses
+ 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...
11th Apr 2018, 7:50 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 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!! -->
11th Apr 2018, 7:43 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 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>
11th Apr 2018, 7:57 PM
Rachael
12th Jun 2018, 3:16 PM
some one
0
I'm sorry, i'm still not getting it :( I'm super new to this
11th Apr 2018, 7:48 PM
Rachael