使用“报”字在html中更改×

时间:2022-09-04 08:18:17

I am using the following code.

我正在使用以下代码。

HTML Code :

HTML代码:

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

Javascript:

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.

我让×警觉。我需要得到和次数作为结果。有人知道这个问题吗?请更新你的建议。

5 个解决方案

#1


30  

You need to escape:

你需要逃离:

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

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

然后使用text()读取值,获取未转义值:

alert($(".test").text()); // outputs: &times

#2


54  

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 ;.)

和乘以是一个乘法符号。(技术上应该是&时间;但是宽大的浏览器可以让您省略;)

#3


3  

I suspect you did not know that there are different & escapes in HTML. The W3C you can see the codes. &times means × in HTML code. Use &amp;times instead.

我怀疑您不知道HTML中有不同的&转义。你可以看到这些代码。报意味着×在HTML代码。使用和时间。

#4


3  

&times; stands for × in html. Use &amp;times to get &times

报;代表×在html。使用和次数获得和次数

#5


0  

Use the &#215 code instead of &times Because JSF don't understand the &times; code.

使用#215代码而不是×,因为JSF不理解×代码。

Use: &#215 with ;

用途:& # 215;

This link provides some additional information about the topic.

这个链接提供了有关这个主题的一些附加信息。

#1


30  

You need to escape:

你需要逃离:

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

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

然后使用text()读取值,获取未转义值:

alert($(".test").text()); // outputs: &times

#2


54  

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 ;.)

和乘以是一个乘法符号。(技术上应该是&时间;但是宽大的浏览器可以让您省略;)

#3


3  

I suspect you did not know that there are different & escapes in HTML. The W3C you can see the codes. &times means × in HTML code. Use &amp;times instead.

我怀疑您不知道HTML中有不同的&转义。你可以看到这些代码。报意味着×在HTML代码。使用和时间。

#4


3  

&times; stands for × in html. Use &amp;times to get &times

报;代表×在html。使用和次数获得和次数

#5


0  

Use the &#215 code instead of &times Because JSF don't understand the &times; code.

使用#215代码而不是×,因为JSF不理解×代码。

Use: &#215 with ;

用途:& # 215;

This link provides some additional information about the topic.

这个链接提供了有关这个主题的一些附加信息。