TooCooL
TooCooL

Reputation: 21162

add two li elements into the end of the ul

here is the jsfiddle that I tried to do this: http://jsfiddle.net/fxMFh/

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>');
});

this must be the problem:

$(".navigation_container nav > ul > li > ul")

I must be doing something very noobish here..

Upvotes: 1

Views: 370

Answers (2)

ryanbrill
ryanbrill

Reputation: 2011

Three problems:

  1. The fiddle doesn't include jQuery.

  2. The selector is missing a div wrapper. It should be:

    $(".navigation_container nav > ul > li > div > ul")

  3. .appendTo() should be .append()

http://jsfiddle.net/ryanbrill/fxMFh/5/

Upvotes: 1

Arun P Johny
Arun P Johny

Reputation: 388326

Try

$(document).ready(function() {
    $(".navigation_container nav > ul > li > div.sub-menu > ul").append('<li><a href="#">test</a></li>');
});

Demo: Fiddle

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>');
});

Demo: Fiddle

Upvotes: 1

Related Questions