jquery not appending with ".append()"

  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

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?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

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.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

Got it, thanks JB

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 132 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.