Hide on click

Discussion in 'JavaScript' started by Finxx, Jul 29, 2012.

  1. #1
    I have a wordpress site I'm trying to put in a cost calculator for my customers. Each field of cost I can create a custom CSS class no problem. What I'm trying to do is have a field hidden unless a certain selection is clicked then I want it to be visible. Here is the code.

    <script type="text/javascript">
    jQuery(document).ready(function(){    
    jQuery(".cvet").hide();   
     jQuery("#jzzf_2_sistema-1").click(function(){jQuery(".cvet").hide();   
         jQuery(".cvet1").fadeIn("slow"); 
       });   
     jQuery("#jzzf_2_sistema-2").click(function(){
    jQuery(".cvet").hide();     
       jQuery(".cvet2").fadeIn("slow"); 
       });}); </script>
    Code (markup):

    I got the code to hide correctly but I cant get it to show. can somebody explain what how to decipher jzzf_2_sistema-1. Can you have underscores and hyphens in css class names or are hyphens referring to something else?? I'm really new to this but I'm learning!
     
    Finxx, Jul 29, 2012 IP
  2. Unni krishnan

    Unni krishnan Peon

    Messages:
    237
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Instead of 'hide' use 'toggle'. The 'toggle' method simply toggles the visibility of elements

    
    jQuery(".cvet").toggle(); 
    
    Code (markup):
     
    Unni krishnan, Jul 30, 2012 IP