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 trialSaqib Ishfaq
13,912 Pointscode not working...
this is my code...
$('.loc').hover(
function(){
$(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">×</span></div></section>'
);
// add the new element to the page
$('#posted-pets').append('$newPet');
});
1 Answer
Matthew Long
28,407 PointsYou've almost got it. Looks like you're appending the string "$newPet"
instead of the variable $newPet
:
$('#posted-pets').append($newPet);
Saqib Ishfaq
13,912 PointsSaqib Ishfaq
13,912 PointsThanks i appreciate it! i looked it over like twice couldn't figure it out what's wrong with the code!