SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: if:checked

  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    if:checked

    Hi all,

    I have a rule that hides an error message if a checkbox has been clicked. I'd like to take it one step further and show the error again if the checkbox is unchecked.

    From my Google hunting, it looks like it will use :checked but I can't seem to get it working!

    Here's what I have.

    Code JavaScript:
    $(document).ready(function{
    	$("input[type=checkbox]").click(   
        function() {   
    	   $(this).parent('label').children('span.error').hide(); 
        }   
    );
    });

    Many thanks

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,907
    Mentioned
    139 Post(s)
    Tagged
    2 Thread(s)
    You don't need :checked here. Just replace .hide() with .toggle()
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Addict
    Join Date
    May 2006
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Haha easy as that?! Works great, thanks : )


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •