Reputation: 4188
I am doing a very simply jQuery select, using a CSS property. Oddly, the value is being returned wrapped in two sets of double quotes?
var font = $(this).css('font-family');
Result comes back as:
font:""Jockey One""
Upvotes: 1
Views: 558
Reputation: 49
font names containing a space are quoted and your font variable is a string. hence the double set of quotes. if you want to ignore the quotes in quoted font names, just do this:
var font = $(this).css('font-family');
font = font.replace(/["']/g, "");
console.log(font);
Upvotes: 1
Reputation: 21489
Font family names containing whitespace should be quoted.
https://developer.mozilla.org/en/docs/Web/CSS/font-family#Values
Also javascript return font-family
name in quote.
console.log($(".noSpace").css("font-family"));
console.log($(".withSpace").css("font-family"));
.noSpace {
font-family: "JockeyOne";
}
.withSpace {
font-family: "Jockey One";
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="noSpace"></div>
<div class="withSpace"></div>
Upvotes: 0