Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Client-side Scripting _ Help! Help a Noob

Posted by: OlleS May 6 2016, 11:16 AM

https://gyazo.com/77426cde9a65c89424d303b4a8ef123d
Hi! I'm completely new to HTML and Javascript and i need help to "connect" a text and a button.
If i click the button i want the text to hide (text) Visibility;hidden but i don't know how to do and i have searched everywere so you guys are my last hope.
Here are the codes:

Button: <button "type=button" "onclick = document.getElementById("Wrong").style.visibility = "hidden";" >Hej</button>

Text: <div id="Wrong"></div><font color="red">Wrong Username Or Password!</font>

Posted by: CharlesEF May 6 2016, 05:37 PM

You almost got it right. Since you have double quotes on the outside you need to either escape the double quotes on the inside or use single quotes instead.

CODE
<button type="button" onclick = "document.getElementById('Wrong').style.visibility = 'hidden';">Hej</button>
Also, your should not include the attribute name inside the double quotes.

Posted by: pandy May 6 2016, 08:05 PM

Hej hej! laugh.gif

Posted by: Frederiek May 7 2016, 07:16 AM

And for the text part, put the closing div at the end, after the obsolete font tag.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)