Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using "&times" word in html changes to ×

I am using the following code.

HTML Code :

<div class="test">&times</div> 

Javascript:

alert($(".test").html()); 

I am getting × in alert. I need to get &times as result.
Anybody knows or faces this problem? Please update your suggestions.

like image 826
Mathi Avatar asked May 30 '13 10:05

Mathi


People also ask

What is the synonym of using?

The words employ and utilize are common synonyms of use. While all three words mean "to put into service especially to attain an end," use implies availing oneself of something as a means or instrument to an end. willing to use any means to achieve her ends.

What is the verb of using?

verb (used with object), used, us·ing. to employ for some purpose; put into service; make use of: to use a knife. to avail oneself of; apply to one's own purposes: to use the facilities. to expend or consume in use: We have used the money provided.

What is an example of use?

Use is the acting of employing or utilizing something or the intended purpose of something. An example of use is the act of hammering with a hammer and nails. An example of use is communication to the Internet. Use is defined as to handle or consume something.

What is the act of using something?

noun. the act of employing, using, or putting into service: the use of tools. the state of being employed or used. an instance or way of employing or using something: proper use of the tool; the painter's use of color. a way of being employed or used; a purpose for which something is used: He was of temporary use.


2 Answers

You need to escape the ampersand:

<div class="test">&amp;times</div> 

&times means a multiplication sign. (Technically it should be &times; but lenient browsers let you omit the ;.)

like image 59
RichieHindle Avatar answered Oct 10 '22 12:10

RichieHindle


You need to escape:

<div class="test">&amp;times</div> 

And then read the value using text() to get the unescaped value:

alert($(".test").text()); // outputs: &times 
like image 30
Strille Avatar answered Oct 10 '22 13:10

Strille