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
  • 5,797
  • 9
  • 25
  • 36

2 Answers2

0

Backslash characters have special meaning.

try:

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

(two backslashes)

Marijn van Vliet
  • 4,961
  • 2
  • 30
  • 45
0

You can try

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

instead off

 $('.someClass').attr('data-content','\f005');
Bhavin Solanki
  • 4,656
  • 3
  • 23
  • 45