JQuery:如何将文本插入HTML ascii字符? [英] JQuery: How to text insert HTML ascii character?

查看:57
本文介绍了JQuery:如何将文本插入HTML ascii字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下JQuery代码:

I have the following JQuery code:

$(this).text('Options ▴');

但是,ascii代码没有显示在我的网页上。所有显示在网页上的是选项▴

However, the ascii code isn't showing up on my web page. All that shows up is on the webpage is Options ▴.

我做错了什么?

推荐答案

使用 .html()方法代替 .text()

.text()方法是使文本与字符串中的文本完全一致,包含所有标记和实体。

The whole point of .text() method is to make the text appear exactly as it's in the string, with all tags and entities.

这篇关于JQuery:如何将文本插入HTML ascii字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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