+ Almost all quality improvement comes via simplification of design, manufacturing... layout, processes, and procedures.

February 4, 2012, 7:25 pm

show div on check for checkbox

December 11, 2007

Sometimes you need to show a div when you click a checkbox, here is how yo do it. You need jquery to establish this.

Code (html)
  1. Check me
  2. <input name="checkbox" type="checkbox" onclick="$(this).is(‘:checked’) && $(‘#checked’).slideDown(‘slow’) || $(‘#checked’).slideUp(‘slow’);" />
  3. <p style="display: none; margin: 10px; height: 100px; background-color: #f5f5f5; padding: 10px" id="checked"> </p>
  4. Put some content here

Basicly the paragraph container named checked is hidden untill one presses the checkbox.

Click here for a demo

Posted by Anthony under jquery,snippets | Comments (7)

7 Comments »

  1. why do i have to leave a comment?

    Comment by Barry Burton — June 18, 2008 @ 3:05 pm

  2. sdfdsfsfxfsf

    Comment by Barry Burton — June 18, 2008 @ 3:05 pm

  3. Hi Barry, you dont have to leave a comment lol. Its a feature built into wordpress.

    Comment by Anthony LeBoeuf — June 18, 2008 @ 3:10 pm

  4. Nice!

    Comment by Nick — August 6, 2008 @ 11:52 am

  5. Hi! I’m Crystal. I am almost 19. :)
    I guess worcesterwideweb.com – nice name for this site! ;)
    It is so interestingly here, especially in this category.
    I was surfed about 3 hours before found this forum. I think i’ll be here for a long time! :-*

    Comment by AMistyCrissy — October 10, 2008 @ 10:34 am

  6. Works great!
    But line 5 is outside the in the code…

    Correct end of the code:
    Put some content here

    Comment by Farid el Nasire — March 5, 2009 @ 4:07 am

  7. Ah yup good call, check the demo it has correct code.

    Comment by Anthony — March 8, 2009 @ 5:56 pm

RSS feed for comments on this post. | Trackback

Leave a comment

XHTML ( You can use these tags): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

*
To prove that you're not a bot, enter this code
Anti-Spam Image