How to use 'click' instead of 'hover' effect

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pano pano
    New Member
    • Nov 2011
    • 18

    How to use 'click' instead of 'hover' effect

    i have this code that works nicely as you can see here.

    here is the code:
    Code:
     <div class='menu'>
        <a href='#'><div class='cat'>title1</div></a>
        <div class='sub_menu'>item1</div>
    </div><div class='menu'>
        <a href='#'><div class='cat'>title2</div></a>
        <div class='sub_menu'>item2</div>
    </div>
    <script>
    $(".cat").hover(function(){
        $(this).parent().parent().find(".sub_menu").hide();
    },
    function() {
        $(this).parent().parent().find(".sub_menu").show();
    });   
    </script>

    How can i have this effect take place on 'mouse click' instead of 'mouse hover'?
    I tried to edit code in many ways but can't figure out the solution.
    thanks in advance
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    use .click() instead of .hover() ?

    Comment

    • pano pano
      New Member
      • Nov 2011
      • 18

      #3
      I tried that, didn't work.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        if it didn’t work, what about error messages?

        Comment

        • pano pano
          New Member
          • Nov 2011
          • 18

          #5
          I don't have any (only some php errors).
          Btw if i don't use <a> tags, hover effect won't work either. I don't know if that has something to do with it.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            Btw if i don't use <a> tags, hover effect won't work either.
            sounds like Internet Explorer.

            Comment

            Working...