使用“& times” html中的单词更改为× [英] Using "&times" word in html changes to ×

查看:1107
本文介绍了使用“& times” html中的单词更改为×的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

HTML代码:

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

Javascript:

 警报($( 测试)的HTML()); 

我在alert中获取×。我需要得到& times 作为结果。

任何人都知道或面临这个问题?请更新您的建议。

解决方案

您需要转义:

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

然后使用 text()读取值以获取非转义值:

  alert($(。test)。text()); //输出:& times 


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.

解决方案

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

这篇关于使用“&amp; times” html中的单词更改为×的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆