jQuery: uniformare l'altezza degli elementi

jQuery: uniformare l'altezza degli elementi

Con jQuery possiamo uniformare l'altezza degli elementi.

Creiamo il seguente plugin:


(function( $ ) {


	$.fn.equalHeight = function() {
		
		return this.each(function() {
		
			var height = Math.max( this.height(), 0 );
			
			this.height( height );
		
		});
	
	
	
	};


})( jQuery );

Il plugin estrae il valore massimo dell'altezza dell'elemento piĆ¹ alto nel set e lo usa per impostare l'altezza dei restanti elementi. Un esempio:


$(function() {

	$( ".box" ).equalHeight();

});
Torna su