How to get attr with raw entities?
Asked Answered
A

2

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.

Airscrew answered 6/3, 2013 at 12:27 Comment(0)
D
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

Darmit answered 6/3, 2013 at 14:14 Comment(0)
O
0

You could set the data attribute by jquery

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

This produces — in the console

Obolus answered 6/3, 2013 at 14:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.