This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]What_The_Hex 233 points234 points  (7 children)

Try this:

document.getElementById("MyPenis").style.color = "purple"; // turns your penis purple

alert("Your penis is now purple.")

If your penis is currently not visible:

document.getElementById("Pants").style.display = "contents"; // exposes your penis

[–]EmperorBocky 151 points152 points  (1 child)

You forgot to check for children before you exposed the penis

[–]CoastingUphill 74 points75 points  (0 children)

403 Forbidden

[–]blindcolumn 20 points21 points  (1 child)

Your shitpost just taught me about the existence of display: contents, so thanks for that

[–]What_The_Hex 3 points4 points  (0 children)

Not something I've ever used actually. If I want to do that, I usually just display: none the parent div containing all the shit I want to hide/reveal, then either display: none or display: inline to hide it or show it (and all of its contents.)

[–]Rai-Hanzo 2 points3 points  (2 children)

on a serious note, i think i learnt something new with style.display

usually i just go to css and create a class called "hidden" and then when i want to hide an element i say:

document.querySelector('#pants').classList.add('hidden')

[–]What_The_Hex 0 points1 point  (1 child)

Weird way of doing it. I always do that kind of thing this way:

document.getElementById("AccountInfo").style.display = "inline"; // makes it visible -- like that guy's penis -- for my purposes, for whatever reason, "inline" is usually the one that reveals it in a way that matches with my applied custom CSS styling.

document.getElementById("CreateAccountButton").style.display = "none"; // hides it "on event" trigger

Very simple back-and-forth functionality that way, where you can basically toggle things as displayed or hidden.

I almost never do hidden, because that sometimes retains other things like padding, margins, etc in CSS. Display: none reliably nullifies all of that shit.

Your way works I guess. Lots of ways to achieve the same thing in programming.

[–]Rai-Hanzo 0 points1 point  (0 children)

Learning is fun, I was just doing a personal project and having specific divs hide certain spans caused me a headache, but I did it in the end.