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 trialLeslie Wolfe
8,700 PointsNot understanding what the "×" is doing.
const $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>'
);
Could someone explain what the last line of code does for this pet adoption app?
<span class="close">×</span>
I can't find it anywhere in the markup. Thanks.
4 Answers
Brice Roberts
22,415 PointsIt is an HTML code for the multiplication symbol.
2 & times ; 2 (no spaces)
would display as
2 x 2
In most programming languages, the "x" is also a math operator for multiplication. So, depending on where you are placing the 'x' , you can confuse the compiler into thinking it needs to multiply.
To make sure that a string is never confusing the compiler, to display an 'x' on your webpage, use
& times ; (no spaces)
in it's place.
Leslie Wolfe
8,700 PointsWait! I got it! It's used as the "x" to close the box (I guess we will learn how to activate that in another video...) It all makes sense now. Thanks so much for your help!
Leslie Wolfe
8,700 PointsThanks Brice. Very helpful. So how is this applicable here?
Brice Roberts
22,415 PointsSorry, I forgot to add that to my initial comment. I just added a bit to my second reply, but in your example, it is just placeholder text for the span.
Leslie Wolfe
8,700 PointsAh, thanks so much. Why do we need a placeholder? Why not just omit that altogether?
Brice Roberts
22,415 PointsBrice Roberts
22,415 PointsI should add, that this is only relevant in code situations outside of a string's value. So, you could safely type
But, if you were concatenating a string,
You can very easily run into issues where an operator is confused with a string, so it is good practice to use × ; in the string.
In your example, the Ć is just used as placeholder text for the span.