So, I have a website with an autoFontSize script (Got it from stackoverflow, but slightly edited it too loop over each div with that specific class)
(function ($) {
$.fn.textfill = function (options) {
this.each(function () {
var fontSize = options.maxFontPixels;
var ourText = $('h2 a', this);
var maxHeight = $(this).height();
var maxWidth = $(this).width();
var textHeight;
var textWidth;
do {
ourText.css('font-size', fontSize);
textHeight = ourText.height();
textWidth = ourText.width();
fontSize = fontSize - 1;
} while ((textHeight > maxHeight || textWidth > maxWidth) && fontSize > 16);
});
return this;
};
})(jQuery);
$(document).ready(function () {
$('.fotonode.fotopagina').textfill({
maxFontPixels: 30
});
});
And a (simplified) HTML structure:
<div class="fotonode fotopagina">
<h2><a href="#">Testing Title</a></h2>
</div>
For some reason this doesn’t work (neither locally nor live) BUT it does work on JSfiddle: http://jsfiddle.net/Yb9yj/
I read somewhere that this can cause problems. I copied the code from jsfiddle to my file, so maybe I have (unintentionally) copied some white spaces that shouldn’t be there or something. I don’t know. But how can I solve this then?
BBEdit’s “Zap Gremlins” feature found an unprintable character at the end of your document. Try deleting that or copying everything in your example up to the last semicolon.