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

Leslie Wolfe
Leslie Wolfe
8,700 Points

Not 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">&times;</span></div></section>'

);

Could someone explain what the last line of code does for this pet adoption app?

<span class="close">&times;</span>

I can't find it anywhere in the markup. Thanks.

4 Answers

Brice Roberts
Brice Roberts
22,415 Points

It 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.

Brice Roberts
Brice Roberts
22,415 Points

I should add, that this is only relevant in code situations outside of a string's value. So, you could safely type

alert("exit");

But, if you were concatenating a string,

alert("Hey, x " + someString + "(2x2)" + (2x2));

You can very easily run into issues where an operator is confused with a string, so it is good practice to use &times ; in the string.

In your example, the Ɨ is just used as placeholder text for the span.

Leslie Wolfe
Leslie Wolfe
8,700 Points

Wait! 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
Leslie Wolfe
8,700 Points

Thanks Brice. Very helpful. So how is this applicable here?

Brice Roberts
Brice Roberts
22,415 Points

Sorry, 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
Leslie Wolfe
8,700 Points

Ah, thanks so much. Why do we need a placeholder? Why not just omit that altogether?