jQuery Drop Down Hover Menu

前端 未结 7 958
隐瞒了意图╮
隐瞒了意图╮ 2020-12-29 06:44

I\'m new to jQuery, I was hoping you guys could help me. I\'m trying to make a hover dropdown menu, but it\'s extremely buggy. Can you help me clean up my Javascript? Loo

7条回答
  •  既然无缘
    2020-12-29 07:28

    To get a select box to open on hover to the exact height required by its contents, figure out how many elements there are:

    JavaScript

    function DropList(idval) {
        //
        // fully opens a dropdown window for a select box on hover
        //
        var numOptgroups = document.getElementById(idval).getElementsByTagName('optgroup').length;
        var numOptions   = document.getElementById(idval).getElementsByTagName('option').length;
        document.getElementById(idval).size = numOptgroups + numOptions;
    }
    

    HTML

    
    

提交回复
热议问题