Jquery :: Populate textfield on image click?

Does anyone happen to know how I would go about populating a text field with x value when a specific image was clicked?

Scenario:

I have a div of 3 images.
Each image represents a different color.

When you click an image… I need a text field to be populated with the color name…

So if you clicked an image that looked like ivory… textfield would then say ivory.

thank you.

Suppose the <img> is like this:

<div class="colours">
  <img src="ivory.jpg" class="ivory">
  <img src="green.jpg" class="green">
  <img src="red.jpg" class="red">
</div>

<input type="text" id="textfield">

Then you do this:

$('.colours img').click(function() {
  $('#textfield').val($(this).attr('class'));
});