10

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
daGrevis
  • 21,014
  • 37
  • 100
  • 139

2 Answers2

2

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

StrubT
  • 998
  • 5
  • 18
0

You could set the data attribute by jquery

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

This produces — in the console

Peter Campbell
  • 661
  • 1
  • 7
  • 35