spezialize Posted November 10, 2014 Share Posted November 10, 2014 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 More sharing options...
0 Seahorsepip Veteran Posted November 10, 2014 Veteran Share Posted November 10, 2014 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 More sharing options...
0 spezialize Posted November 11, 2014 Author Share Posted November 11, 2014 It actually doesn't add the option to the navigation. Sorry for the confusion. Link to comment Share on other sites More sharing options...
0 adrynalyne Posted November 11, 2014 Share Posted November 11, 2014 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 More sharing options...
0 Seahorsepip Veteran Posted November 11, 2014 Veteran Share Posted November 11, 2014 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 More sharing options...
0 spezialize Posted November 12, 2014 Author Share Posted November 12, 2014 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 More sharing options...
0 Seahorsepip Veteran Posted November 12, 2014 Veteran Share Posted November 12, 2014 Hm it was not showing up for me. The grey menu bar is the place I want it. Seems to work fine: Link to comment Share on other sites More sharing options...
Question
spezialize
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.
site is daddyleagues.com/premier
Link to comment
Share on other sites
6 answers to this question
Recommended Posts