tags:

views:

105

answers:

2

I have the following:

<table id="StateNames">
<tr>
<td><input name="StateName"></td>
</tr>
<tr><td>Wyoming</td></tr>
<tr><td>Wisconsin</td></tr>
<tr><td>West Virginia</td></tr>
</table>

I'd like to

$('input').change(function() {
   var StateName = $(this).val();
   insert <tr><td>StateName</td></tr> before Wyoming
+1  A: 
Tatu Ulmanen
there's a ")" missing after the "}"...
j.
Yes, I was having a hard time explaining what I wanted without being able to point to "there" and saying "right there".But your assumption was correct.
cf_PhillipSenn
A: 

Like this:

var newElem = $('<tr></tr>').append($('<td></td>').text(StateName));
$(this).closest('tr').after(newElem);

Or:

$('tr:contains(Wyoming)').before(newElem);
SLaks