1

I am trying to set font from jquery with the data attribute and for some reason the icon is not displaying and i see the actual text.

.someClass {
    position: relative;
    white-space: nowrap;
    display: inline-block;
    cursor: pointer;
    &::before, span::before {
        font-family: FontAwesome;
        text-shadow: .05em .05em #aaa;
        content: attr(data-content);
        color: #AAA;
        font-size: rem-calc(20px);
        line-height: 1;
        letter-spacing: 4px;
    }
}

 $('.someClass').attr('data-content','\f005');

And when i do this without jquery like this, it is working:

   content: "\f005";
user233232
  • 6,067
  • 9
  • 29
  • 37

2 Answers2

0

Backslash characters have special meaning.

try:

$('.someClass').attr('data-content','\\f005');

(two backslashes)

Marijn van Vliet
  • 5,239
  • 2
  • 33
  • 45
0

You can try

 $('.someClass').css('content','\f005');

instead off

 $('.someClass').attr('data-content','\f005');
Bhavin Solanki
  • 4,740
  • 3
  • 26
  • 46