I have data attr on my tag. Data attr has HTML entity in it. I can get content of that attr with data method from jQuery. However, HTML entity is modified and instead of getting — I get .

How to get the raw content?

JsFiddle demo.

有帮助吗?

解决方案

I think that is not possible. As I understand it, the browser automatically resolves —, therefor you would have to encode it server-side to —.

jsFiddle

其他提示

You could set the data attribute by jquery

$("span").data("foo", "—");
console.log($("span").data("foo"));

This produces — in the console

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top