Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Introduction to jQuery DOM Manipulation Adding Content to the Page

Karl Pupé
Karl Pupé
6,718 Points

I don't know what I am doing wrong but my code doesn't seem to work...

Hi! I am following along with the video and I feel that I have done everything that Aisha done and it doesn't work! I checked the console and nothing showing up! Here's my code:

// Adds a pet to the page with user on button click
$('#add-pet').on('click', function() {


  // Grab info from the form

  var $name = £('#pet-name').val();
  var $species = £('#pet-species').val();
  var $notes = £('#pet-notes').val();

  //Assemble the HTML of our new element with the above variables

  var $newPet = $(
     '<section class="six columns"><div class="card"><p><strong>Name:</strong> ' + $name + 
     '</p><p><strong>Species:</strong> ' + $species +  
     '</p><p><strong>Notes:</strong> ' + $notes + 
     '</p><span class="close">&times;</span></div></section>'  
  );

  // Attach the new element to the page
  $('#posted-pets').append($newPet);

});

Thank you for all your help! I appreciate it!

1 Answer

andren
andren
28,558 Points

While the pound has lost some value lately I wouldn't say its equal to the dollar just yet...

var $name = £('#pet-name').val();
var $species = £('#pet-species').val();
var $notes = £('#pet-notes').val();

Put in a less convoluted way you have mixed up $ and £ in your code. JQuery is not currency agnostic, only $ is accepted. If you fix those typos your code will probably work.

Karl Pupé
Karl Pupé
6,718 Points

Hehe! I think that Brexit screwed with my brain! Perfect! It got my code working!

Thank you so much!