• 0

jquery adding to list


Question

I am trying to use jquery to add some options into a list. This website automatically creates the navigation for me so I have added some jquery to remove some items off the list, however I am now trying to add additional options.

 

ex. 

$("#daddyleagues-menu .navbar .nav > li:contains('Chat')").remove();
	$("#daddyleagues-menu .navbar .nav > li:contains('Forum')").remove();
	$("#daddyleagues-menu .navbar .nav > li:contains('Blog')").remove();
	$("#daddyleagues-menu .navbar .nav").append('<li><a href="/user/messages"><span class="tab">Message Center</span></a></li>');

site is daddyleagues.com/premier

 

 

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

What's the actual problem?

I only see some unnecessary <span> in your append() which makes the nav item look different so to prevent that use the append function without a <span>:

$("#daddyleagues-menu .navbar .nav").append('<li><a href="/user/messages">Message Center</a></li>');

So is that the problem or?

Link to comment
Share on other sites

  • 0

My first thought is that you don't need all that.

 

$("#daddyleagues-menu").append('<li><a href="/user/messages">Message Center</a></li>')

 

Works the same unless you violated HTML5 standards and are reusing ids.

 

My second thought is, where are you adding it?  If it works in a developer console, then you probably aren't adding it after the DOM is ready.

 

Enclose it in $(document).ready(function () { });

Link to comment
Share on other sites

  • 0

It actually doesn't add the option to the navigation. Sorry for the confusion.

It does, it's added to the bottom grey menubar...

If you want to add it to the top blue menubar you need to use the correct selector.

Link to comment
Share on other sites

  • 0

It does, it's added to the bottom grey menubar...

If you want to add it to the top blue menubar you need to use the correct selector.

 

Hm it was not showing up for me. The grey menu bar is the place I want it.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.