Replace a dropdown list in the last row of a table with text
I have an html table and in one column I have dropdown select. I would like a selector to get a handle to the dropdown in the last row of the table and change it to just regular text (using the value in the select). here is the tricky part, in some cases the last row will not have a dropdown and it will just be text in this cell and in this case i want to do nothing.
So I am needing something that supports the following logic:
Get dropdown select in lastrow of table a开发者_开发百科nd convert to text. If there is no dropdown in that cell then do nothing.
Ok, you can just do this, assuming the text you want to replace the select
with is in the variable textValue
and the table has the id tableid
:
$('#tableid tr:last select').replaceWith(textValue)
精彩评论