jquery: replace & restore

see http://stackoverflow.com/questions/4004731/jquery-storing-content-of-select-box-to-variable/4004823#4004823

HTML

<body>
 <select id="target" size="3">
  <option>a
  <option>b
  <option>c
</select>
<input type="button" 
       value="replace"
       onclick="fx($('#target'),this)"
       />
</body>

JavaScript

function fx(o,b)
{
  if(b.value==='replace')
  {
    o.data('defaults',$('option',o).replaceWith('<option>1</option><option>2</option><option>3</option>'));
    $(b).val('restore');
  }
  else
  {
    $(o).empty().append($(o).data('defaults'));
    $(b).val('replace');
  }
}