[jQuery] Changing text to a pulldown (select) menu on click
Hello all,
a quick question the answer to which I hope I have not missed in the
documentation: I have a table of data and I want to make one of the
cells to provide a pull down menu (the <select> form element) when
clicked on. Being a rank amateur, the only idea I could come up with
is something like this:
<td id='mycell'>
<div id='valtext'>Current</div>
<div id='valopts' style='display: none;'>
<select id='selopts'>
<option>Old</option>
<option>Current</option>
<option>New</option>
</select>
</div>
</td>
and something like this in jQuery:
$('#valtext').click(function() { $(this).hide(); $
('valopts').show(); });
and similarly, a $('#selopts').change() that hides 'valopts', sets the
contents of 'valtext' to the value selected in 'selopts' and shows
'valtext'.
Is this the right approach? Or is there a simpler method that I am
unaware of?
Thank you,
--ravi