Jquery function

Hi there,
could someone please explain the following function to me:


	// image deletion function
		var recycle_icon = "<a href='link/to/recycle/script/when/we/have/js/off' title='Recycle this image' class='ui-icon ui-icon-refresh'>Recycle image</a>";
		function deleteImage( $item ) {
			$item.fadeOut(function() {
				var $list = $( "ul", $trash ).length ?
					$( "ul", $trash ) :
					$( "<ul class='gallery ui-helper-reset'/>" ).appendTo( $trash );


				$item.find( "a.ui-icon-trash" ).remove();
				$item.append( recycle_icon ).appendTo( $list ).fadeIn(function() {
					$item
						.animate({ width: "48px" })
						.find( "img" )
							.animate({ height: "36px" });
						 	
				});
				
			});
		}

In particular, I do not follow:

  		var $list = $( "ul", $trash ).length ?
				$( "ul", $trash ) :
				$( "&lt;ul class='gallery ui-helper-reset'/&gt;" ).appendTo( $trash );

thanks

? is the ternary operator, which acts like a compact if-else statement. That code is equivalent to:


if ($( "ul", $trash).length) {
    var $list = $( "ul", $trash );
} else {
    var $list = $( "<ul class='gallery ui-helper-reset'/>" ).appendTo( $trash );;
}

Thankyou very much :wink: