// make sure the $ is pointing to JQuery and not some other library (function($){ // add a new method to JQuery $.fn.equalHeight = function() { // console.log('sidebare -> '+$('#sidebar').height()+'| main -> '+$('#main').height()+' | screen -> '+screen.height); /*if($('#sidebar').height()<=$('body').height() && $('#main').height()<=$('body').height()) { console.log('cas 0'); $('#sidebar').height($('body').height()-92); $('#main').height($('body').height()-92); } else if($('#sidebar').height()<=$('#main').height()) { console.log('cas 1'); $('#sidebar').height($('#main').height()); } else if($('#sidebar').height()>$('#main').height()) { console.log('cas 2'); $('#sidebar').height($('body').height()); $('#main').height($('body').height()); } */ if ($('#sidebar').height() < $('body').height()) $('#sidebar').height($('body').height()); if ($('#main').height() < $('body').height()) $('#main').height($('body').height()); if ($('#main').height() < $('#sidebar').height()) $('#main').height($('#sidebar').height()); if ($('#sidebar').height() < $('#main').height()) $('#sidebar').height($('#main').height()); /* console.log($(document).height()); if($("#sidebar").height() < $(window).height()){ $("#sidebar").height($(document).height()) ; } */ $('#main').resize(function() { console.log('ok'); }); } })(jQuery);