I think my code is creating an infinite loop.
- The page never finishes loading.
- It "locks up" and Chrome is forced to kill the offending page.
- The console doesn't refresh, so I can't read the errors.
The problem I'm trying to solve is having some text elements that are sometimes too wide, but resizing ALL of the text would make some of them really small.
My solution was to go to each header ('.mftitle h1')
and compare it to it's container ('.ut-one-third')
that is always an acceptable width. If the header is wider than the container, then it reduces the font-size until it isn't.
jQuery( document ).ready(function() {
jQuery('.mftitle h1').each(function() {
var container = jQuery(this).closest('.ut-one-third');
while( jQuery(this).width() > jQuery(container).width() ) {
jQuery(this).css('font-size', (parseInt(jQuery(this).css('font-size')) - 1) + "px" );
}
});
});
Thank you for any help! I'm stumped. And apologies if this is an awful solution, I'm teaching myself jQuery.