jquery菜单

 首先把DataTabl中的数据读出来

后台

private void bind()
        {
            BLL.Channel ch = new BLL.Channel();
            DataTable dt;
            string where = "";
            dt = ch.GetList(0,2);
            if (ClassId == 127)
            {
                where = "kindid=4 and Parentid=0";
                dt = ch.GetList(0,4);
            }
            if (ClassId == 73)
            {
                where = "kindid=3 and Parentid=0 and id<>199";
                dt = ch.GetList(100, where, "Id asc");
            }
            if (ClassId == 128)
            {
                where = "kindid=2 and Parentid=0";
                dt = ch.GetList(0,2);
            }
            
            Repeater2.DataSource = dt;
            Repeater2.DataBind();


        }

前台

<asp:Repeater ID="Repeater2" runat="server" 
                                      onitemdatabound="Repeater2_ItemDataBound">
                                  <ItemTemplate>
                                <asp:HiddenField ID="txtClassId" runat="server" Value='<%#Eval("ClassLayer") %>' />
                                <li class='<%#Eval("ClassLayer") %>' id='<%#Eval("parentid") %>' title='<%#Eval("id") %>'><a href='<%#ActionLabel.Products.GetUrl(ClassId,(int)Eval("id")) %>'>
                                    <asp:Literal ID="Literal1" runat="server"></asp:Literal><%#Eval("Title") %></a> </li>
                              
                                  
                                  </ItemTemplate>
                                  </asp:Repeater>

js

$(function () {



    $(".cla li.2,.cla li.3").hide();

    $(".cla li.1").mouseover(function () {

        $(".cla li[id=" + $(this).attr("title") + "]").show(); 
     


        $(".cla li[id!=" + $(this).attr("title") + "][id!=0]").hide();

    });

    $(".cla li.2").mouseover(function () {
        $(".cla li[id=" + $(this).attr("title") + "]").show();

        $(".cla li[id!=" + $(this).attr("title") + "][class=3]").hide();
    });
});

posted on 2012-06-28 19:15  Demon Edge  阅读(384)  评论(0)    收藏  举报