I have a small problem. I want to change glyphicons (icon-font) using jQuery, like this:
var icoList = 'E251'
var icon = $('ul > li:has(ul)', $this);
icon.addClass('icon');
icon.attr('data-before', '&#x' + icoList); // this doesn' work, -> 
icon.attr('data-before', '\' + icoList); // this doesn' work, -> TypeError
icon.attr('data-before', '\\' + icoList); // this doesn' work, -> \E251
icon.attr('data-before', '"\\' + icoList + '"'); // this doesn' work, -> "\E251"
I only get a string.
My css is like this:
ul li::before {
font-family: "Glyphicons Halflings";
content: attr(data-before);
}
In my HTML I tried this:
<nav id="Nav-Main" class="nav-main">
<ul>
<li data-before=""> <!-- this works fine -->
<a href="#">Home</a>
<ul class="flexy">
<li>
<a href="#">Referenzen</a>
</li>
<li>
<a href="#">Downloads</a>
</li>
</ul>
</li>
</ul>
</nav>
If I use the Data in my html code, then it works fine.
What did I do wrong? How I can get this icon using code?