我试图has在我的一个菜单中使用 jQuery 的方法来检查当前是否<li>有任何菜单<ul>。如果是,则显示它们,否则隐藏li.
但是在使用has时出现此错误:
未捕获的类型错误:对象 # 没有方法“有”
我的代码:
$('nav ul li').click(function () {
console.log(this.has('ul')); //Checking
if ($(this).children('ul').is(":visible")) {
$(this).children('ul').slideUp(250);
} else {
$(this).children('ul').slideDown(250);
}
});