Основной код: index.php
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.fittext.js"></script>
<ul id="menu">
<li>
<a href="#" name="menu1.php" id="tabs1" >меню1</a>
</li>
<li>
<a href="#" name="menu2.php" id="tabs3" >меню2</a>
</li>
</ul>
<div id="content"></div>
<script language="javascript">
//Кеширование элементов меню
var menu=$('#menu').children('li');
var menu_link=$(menu).children('a');
$(menu_link).click(activeElement);
function load_content(obj){
$.get($(obj).attr('name'),function(response, status, xhr){
$('#content').html(response);
});
}
function activeElement(obj) {
load_content($(this));
});
}
</script>
Файл menu1.php который подгружается для пункта меню1
<div class="home_service">
<p>что-то.</p>
</div>
<script type="text/javascript">
$(".home_service p").fitText(6);
</script>
Плагин jquery.fitText.js
(function( $ ){
$.fn.fitText = function( kompressor, options ) {
var settings = {
'minFontSize' : Number.NEGATIVE_INFINITY,
'maxFontSize' : Number.POSITIVE_INFINITY
};
return this.each(function(){
var $this = $(this); // store the object
var compressor = kompressor || 1; // set the compressor
if ( options ) {
$.extend( settings, options );
}
// Resizer() resizes items based on the object width divided by the compressor * 10
var resizer = function () {
$this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
};
// Call once to set.
resizer();
// Call on resize. Opera debounces their resize by default.
$(window).resize(resizer);
});
};
})( jQuery );