Jquery 如何仅从td中删除文本?
这是myJquery 如何仅从td中删除文本?,jquery,Jquery,这是mytd的HTML: <td class="SmallCols PadOn"> 6 <input type="hidden" id="HiddenID" value="0" name="HiddenID"> </td> 寻求帮助和建议。谢谢这个问题是因为closest()在DOM树上,而您需要在树下查找子元素,因此应该使用find()。另外,end()调用也是多余的。试试这个: var cloneTr = $('#StudentGrid
td
的HTML:
<td class="SmallCols PadOn">
6
<input type="hidden" id="HiddenID" value="0" name="HiddenID">
</td>
寻求帮助和建议。谢谢这个问题是因为
closest()
在DOM树上,而您需要在树下查找子元素,因此应该使用find()
。另外,end()
调用也是多余的。试试这个:
var cloneTr = $('#StudentGrid tr:last').clone();
cloneTr.find('td').contents().filter(function() {
return this.nodeType === 3;
}).remove();
没问题,很乐意帮忙。
var cloneTr = $('#StudentGrid tr:last').clone();
cloneTr.find('td').contents().filter(function() {
return this.nodeType === 3;
}).remove();