开发者

Multi-level drop-down context menu

I am making a context(right click) menu plugin for jQuery, and it works fine for the first level. But I need it to have infinite levels. I already have the recursion down, but I think it's a problem with the showing/hiding. This is my code, so far: http://jsfiddle.net/H7GqA/4/ (Sorry for the messy code, plugin's for myself). The second-level item never appears, and I'm not sure wha开发者_JS百科t i'm doing wrong.

Thanks in advance - Tanner.


You have display:none on the .submenu elements and you do nothing to show them.

If you want them to be always on add the following rule

#ContextMenu .submenu {
    display:block;
}

if you want to do it on hover of their parent do

for modern browsers

#ContextMenu .item:hover > .submenu {
    display:block;
}

I see the you have this code

    cm.find(".item:has(.submenu)").hover(function(){
        //$(this).find("ul").css('display', 'block');
        //alert('blabla_1');
        $(this).css('background-color', 'red');
    });

the should work (if you uncomment the first line) and move that code in the doMain function. Because where you currently have it the #ContextMenu element does not exist yet.. so the binding does not happen..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜