在ul的末尾添加两个li元素 [英] add two li elements into the end of the ul
本文介绍了在ul的末尾添加两个li元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我尝试执行的 jsfiddle : http://jsfiddle.net/fxMFh/
我想用jquery在子菜单的末尾添加两个li,但这似乎无法导航到它需要的ul:
I want to add two li's into the end of the submenu with jquery, but this seems that doesnt navigate to the ul it needs to:
$(document).ready(function() {
$(".navigation_container nav > ul > li > ul").append('<li><a href="#">test</a></li>');
});
这一定是问题所在
$(".navigation_container nav > ul > li > ul")
我必须在这里做一些无味的事情.
I must be doing something very noobish here..
推荐答案
尝试
$(document).ready(function() {
$(".navigation_container nav > ul > li > div.sub-menu > ul").append('<li><a href="#">test</a></li>');
});
演示:小提琴
但可能我会将选择器缩短为
But probably I will shorten the selector to
$(document).ready(function() {
$(".navigation_container nav div.sub-menu > ul").append('<li><a href="#">test</a></li>');
});
演示:小提琴
这篇关于在ul的末尾添加两个li元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文