Javascript jquery切换类延迟时间
假设我在母版页上有一个菜单栏的代码 这是填充菜单条形码Javascript jquery切换类延迟时间,javascript,jquery,html,css,Javascript,Jquery,Html,Css,假设我在母版页上有一个菜单栏的代码 这是填充菜单条形码 private void PopulateMenu() { List<BOMsMenu> ListMenuParent = new List<BOMsMenu>(); List<BOMsMenu> ListMenuChild = new List<BOMsMenu>(); DACommon common = new DACommon();
private void PopulateMenu()
{
List<BOMsMenu> ListMenuParent = new List<BOMsMenu>();
List<BOMsMenu> ListMenuChild = new List<BOMsMenu>();
DACommon common = new DACommon();
ListMenuParent = common.GetParentMenu(UserLogin.AuthorityAccessID, UserLogin.UserName);
string innerHTML = string.Empty;
if (common.MsgCode == 0)
{
common = new DACommon();
List<int> ListParentID = (from a in ListMenuParent
where a.IsParent == true
select a.IDMenu).ToList();
ListMenuChild = common.GetChildMenu(ListParentID, UserLogin.AuthorityAccessID);
if (common.MsgCode == 0)
{
for (int i = 0; i < ListMenuParent.Count; i++)
{
if (!ListMenuParent[i].IsParent)
{
innerHTML += "<li><a href=\"" + ListMenuParent[i].FormName + "\" class=\"no-sub\"> " + ListMenuParent[i].MenuName + "</a></li>" + Environment.NewLine;
}
else
{
innerHTML += "<li class=\"has-sub\"><a href=\"" + ListMenuParent[i].FormName + "\">" + ListMenuParent[i].MenuName + "<span class=\"sub-arrow\"></span></a>" + Environment.NewLine + "<ul>" + Environment.NewLine;
for (int j = 0; j < ListMenuChild.Count; j++)
{
if (ListMenuChild[j].IDParent == ListMenuParent[i].IDMenu)
{
innerHTML += "<li class=\"sub-menu\"><a href=\"" + ListMenuChild[j].FormName + "\">" + ListMenuChild[j].MenuName + "</a></li>" + Environment.NewLine;
}
}
innerHTML += "</ul>" + Environment.NewLine + "</li>" + Environment.NewLine;
}
}
}
divMenuBar.InnerHtml = innerHTML;
}
}
用于运行jquery的脚本
$(document).ready(function (e) {
$('.has-sub').click(function () {
$(this).toggleClass('click');
});
$('.has-sub li a').click(function (e) {
e.stopPropagation();
});
});
以及如何延迟切换类,使子菜单的动画切换更加平滑?A接受以下参数
( className [, switch ] [, duration ] [, easing ] [, complete ] )
因此,可以像这样添加延迟
$(this).toggleClass('click',2000);
其中,数字2000
是确定动画将运行多长时间的持续时间。A接受以下参数
( className [, switch ] [, duration ] [, easing ] [, complete ] )
因此,可以像这样添加延迟
$(this).toggleClass('click',2000);
其中,数字
2000
是确定动画将运行多长时间的持续时间。可能重复的nvm mister已从其他问题thx获得答案,用于提醒可能重复的nvm mister已从其他问题thx获得答案reminding@NewbieProgrammer乐意help@NewbieProgrammer高兴的帮助