jquery not appending with ".append()"

  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Joined: Aug 04, 2008
  • Posts: 846
  • Status: Offline

Post January 26th, 2010, 5:35 pm

I have this code that should be appending an li to a ul. I wrote an array to tell it what the pages are and what the text in the link should be. It's not generating the link though.

JAVASCRIPT Code: [ Select ]
var link1=newArray();
      link1[0] = "index.html";
      link1[1] = "Home";
 
$('#navigation ul li:nth-child(1)').append('<a href="' + link1[0] + '">' + link1[1] + '</a>');
 
  1. var link1=newArray();
  2.       link1[0] = "index.html";
  3.       link1[1] = "Home";
  4.  
  5. $('#navigation ul li:nth-child(1)').append('<a href="' + link1[0] + '">' + link1[1] + '</a>');
  6.  


Obviously there are more arrays, one for each link in the navigation menu, but I figure I better get the first one working before I move on. Any ideas?
Use your words like arrows to shoot toward your goal.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 26th, 2010, 5:35 pm

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13458
  • Loc: Florida
  • Status: Offline

Post January 26th, 2010, 6:43 pm

If that's verbatim, you have a syntax error on the first line in the form of a missing space between "new" and "Array".

Other than that, in my experience with jQuery when append/prepend and family don't work right it's because my selector isn't targeting what I thought it was.
Strong with this one, the sudo is.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Joined: Aug 04, 2008
  • Posts: 846
  • Status: Offline

Post January 26th, 2010, 6:59 pm

Got it, thanks JB
Use your words like arrows to shoot toward your goal.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 100 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.