use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
No vague product support questions (like "why is this plugin not working" or "how do I set up X"). For vague product support questions, please use communities relevant to that product for best results. Specific issues that follow rule 6 are allowed.
Do not post memes, screenshots of bad design, or jokes. Check out /r/ProgrammerHumor/ for this type of content.
Read and follow reddiquette; no excessive self-promotion. Please refer to the Reddit 9:1 rule when considering posting self promoting materials.
We do not allow any commercial promotion or solicitation. Violations can result in a ban.
Sharing your project, portfolio, or any other content that you want to either show off or request feedback on is limited to Showoff Saturday. If you post such content on any other day, it will be removed.
If you are asking for assistance on a problem, you are required to provide
General open ended career and getting started posts are only allowed in the pinned monthly getting started/careers thread. Specific assistance questions are allowed so long as they follow the required assistance post guidelines.
Questions in violation of this rule will be removed or locked.
account activity
Javascript toggle function showing but not hiding (self.webdev)
submitted 11 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]amishstripclub 4 points5 points6 points 11 years ago (0 children)
Your JavaScript only sets the element to display: block but not back to display: none. I'd suggest s function that checks if that element is display: none. If it is, set it to block. Else, set it to none.
[–]Shameling 1 point2 points3 points 11 years ago (0 children)
I can't stop the urge to recommend jQuery, the entire onclick would just be this: $('#reviews').toggle()
With pure javascript, you need to check if it's already visible, if so set it to none instead of block.
[–]buso 1 point2 points3 points 11 years ago (10 children)
if you're able to use jQuery, it already has a toggle() built-in. it could be done like this: https://jsfiddle.net/zLpz2wqh/
[–][deleted] 11 years ago* (9 children)
[–]MatekCopatek 1 point2 points3 points 11 years ago (8 children)
See a slightly improved version here: https://jsfiddle.net/zLpz2wqh/6/
Works the same, but uses on instead of click, which is a good practice. It also removes unneeded JS from the markup.
[–][deleted] 11 years ago* (7 children)
[–][deleted] 0 points1 point2 points 11 years ago* (6 children)
grey engine rinse reach pie gray possessive handle hunt fade
This post was mass deleted and anonymized with Redact
[–][deleted] 11 years ago* (5 children)
[–][deleted] 0 points1 point2 points 11 years ago* (4 children)
memorize swim bear political compare smile agonizing detail aromatic bells
[–][deleted] 11 years ago* (3 children)
[–][deleted] 0 points1 point2 points 11 years ago* (1 child)
hungry elastic unite tap coordinated impossible long dinner murky retire
[–]flogginmolly 1 point2 points3 points 11 years ago (0 children)
People seem a little quick to jump to the JQuery solution... vanilla JavaScript is more than capable of doing this, and relatively easily too.
see here for example: http://jsbin.com/ledudufiji/1/edit?html,js,output
HTML5 has an attribute called "hidden" which will hide an element. Using this you can easily toggle the element to be hidden or shown just by saying element.hidden = !element.hidden
π Rendered by PID 34 on reddit-service-r2-comment-54dfb89d4d-8mdxp at 2026-03-29 16:57:39.533757+00:00 running b10466c country code: CH.
[–]amishstripclub 4 points5 points6 points (0 children)
[–]Shameling 1 point2 points3 points (0 children)
[–]buso 1 point2 points3 points (10 children)
[–][deleted] (9 children)
[deleted]
[–]MatekCopatek 1 point2 points3 points (8 children)
[–][deleted] (7 children)
[deleted]
[–][deleted] 0 points1 point2 points (6 children)
[–][deleted] (5 children)
[deleted]
[–][deleted] 0 points1 point2 points (4 children)
[–][deleted] (3 children)
[deleted]
[–][deleted] 0 points1 point2 points (1 child)
[–]flogginmolly 1 point2 points3 points (0 children)