1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

divs hiding under each other

Discussion in 'JavaScript' started by dethfire, Sep 24, 2010.

  1. #1
    I have this simple checkbox menu
    http://myresearchfinder.com/dev/checktest.html

    If you check the cancer box a div will appear. If you check lung, another menu pops up. If you check colon nothing appears because it's behind the lung div. I am aware of z-index. But because a person may go back and forth between menus I need a way to make sure the appropriate div is always on top. Any ideas?
     
    dethfire, Sep 24, 2010 IP
  2. clockedout7

    clockedout7 Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this:

    
    <script>
    
    var zindex=20;
    
    function gofade(clicker,fadediv)
    {
    
    if ($(clicker).attr("checked")) {
            //do stuff if the checkbox is checked
    		$(fadediv).css("z-index",zindex.toString());
    
    		$(fadediv).fadeIn("slow");
    		zindex+=1;
        } else {
            //do stuff if the checkbox isn't checked
    		$(fadediv).fadeOut("slow");
    		zindex-=1;
        }
    
    }
    
    /*
    
    $('#lung').click(function () {
        if ($(this).attr("checked")) {
            //do stuff if the checkbox is checked
    		$("#two").fadeIn("slow");
        } else {
            //do stuff if the checkbox isn't checked
    		$("#two").fadeOut("slow");
        }
    });
    
    */
    	   
    </script>
    
    Code (markup):
     
    clockedout7, Oct 5, 2010 IP