question about improper function ?

question about improper function ?

trying to make a dropdown menu clickable on and off... but also be able to turn it off with clicking outside of it.  This works great (this is just for the turning it off part, getting the menu to drop down is working fine):

  $(document) .mouseup(function (e){
      var ch = "#dropdownmenu";
        if (!$(ch).is(e.target) // if the target of the click isn't the container...
        && $(ch).has(e.target).length === 0) // ... nor a descendant of the container
        {
        $(ch).hide(200);
        }
})



but when I try to make it into a function that I could apply for all my dropdown menus, it doesn't work:



var dropC = function(ch) {
      
    $(document) .mouseup(function (e){
        if (!$(ch).is(e.target) // if the target of the click isn't the container...
        && $(ch).has(e.target).length === 0) // ... nor a descendant of the container
        {
        $(ch).hide(200);
        }
})

}





FYI  here's the other part of the code for getting the menu to come down:

var dropC = function(child, parent){
    $(parent) .click(function(){
        if ($(child).is(" :hidden")){
        $(child) .show(200);
        }
})

}