How to remove all tags: table
, tbody
, tr
from my HTML code ? At the end I would like replece all
<td>
<input id="selectOne" type="radio" value="1" name="selectOneRadio">
</td>
with
<li>
<input id="selectOne" type="radio" value="1" name="selectOneRadio">
</li>
I need a jQuery function. Please help me :)
<table>
<tbody>
<tr>
<td>
<input id="selectOne" type="radio" value="1" name="selectOneRadio">
<label for="selectOne">
</td>
</tr>
</tbody>
</table>
from comment...
The label
element should stay. I tried with:
$('table td').each(function () {
$(this).replaceWith(function () {
return $('<li>' + this.innerHTML + '</li>')
})
});
and then
jQuery.fn.unwrap = function (el) {
return this.each(function () {
$(this.childNodes).appendTo(this.parentNode);
});
};
$('tr, table, tbody').unwrap().remove();
but it doesn't work for me.