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

Saqib Ishfaq
Saqib Ishfaq
13,912 Points

code not working...

this is my code...

    $(this).html("<strong>Location:</strong> Your house?!");
  function() {
    $(this).html("<strong>Location:</strong> Treehouse Adoption Center");

//add a pet to the page with user input
$('#add-pet').on('click', function(){
  //grab info from the post form input elements and store in the JQ variables

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

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

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



1 Answer

Matthew Long
Matthew Long
28,407 Points

You've almost got it. Looks like you're appending the string "$newPet" instead of the variable $newPet:

Saqib Ishfaq
Saqib Ishfaq
13,912 Points

Thanks i appreciate it! i looked it over like twice couldn't figure it out what's wrong with the code!