最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTML Entities with jQuery - Stack Overflow

programmeradmin3浏览0评论

I would like to use replace the value of a submit button with Loading….

The problem is that when I click the button I still see … instead of three dots.

Here's my code:

$("#myid").val("Loading…");

Should I enter the ellipsis directly from the keyboard in the code above? Is it safe with UTF-8?

I would like to use replace the value of a submit button with Loading….

The problem is that when I click the button I still see … instead of three dots.

Here's my code:

$("#myid").val("Loading…");

Should I enter the ellipsis directly from the keyboard in the code above? Is it safe with UTF-8?

Share Improve this question edited Dec 27, 2016 at 13:38 Daniel Gray 1,7923 gold badges22 silver badges46 bronze badges asked Sep 13, 2009 at 14:02 collimarcocollimarco 35.4k37 gold badges115 silver badges155 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 17

val() or value sets a plain text value. … is HTML, not text; you could use it in innerHTML or .html(), but not in a form field value.

If you want to include U+2026 HORIZONTAL ELLIPSIS in a JavaScript string where the encoding is not guaranteed, you could escape it to:

'Loading\u2026'

Should I enter the ellipsis directly from keybord in the code above? Is it safe with UTF-8?

Yes.

However, the ellipsis has a compatibility decomposition into three period characters; it is really only there for backwards compatibility with older character sets. These days the idea is just to use three periods, and let the font deal with coming up with combined glyphs if necessary. In any case, there is little to no visual difference between three periods and an ellipsis in most (proportional) fonts.

Just as note, these are the useful spanish characters

\u00E1  á
\u00E9  é
\u00ED  í
\u00F1  ñ
\u00F3  ó
\u00FA  ú

\u00C1  Á
\u00C9  É
\u00CD  Í
\u00D1  Ñ
\u00D3  Ó
\u00DA  Ú

I've created a useful tool to convert whatever you want to the corresponding \uVALUE in JS :) http://jsfiddle.net/tomasdev/VjAkJ/

发布评论

评论列表(0)

  1. 暂无评论