I want to assign an icon from an iconfont to a span element with a before pseudo element. The value of the icon is dynamically written to the HTML as data attribute.
Unfortunately, in the following example, the HTML does not show the icon, but "\EA46". Probably it is because of the backslash. Does anyone have an idea how I could solve this?
.testicon {
font-family: iconFont;
}
[data-icon]:before {
content: attr(data-icon);
}
<span class="testicon" data-icon="\EA46"></span>