有一段html代碼,如下,我想復(fù)制tr中的內(nèi)容,然后after 到別的地方
<tr>
? ? ? ? ? ? <td style="text-align: center;"></td>
? ? ? ? ? ? ? ? ? <td>
? ? <select class="form-control sku_select" name="sku[]"data-placeholder="Select a Sku"
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? " >
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <option value="">select sku</option>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </select>
? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? <td>
? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? <td><input type="text" name='quantity' value="" style="width: 50px;"></td>
? ? ? ? ? ? ? ? ? <td></td>
? ? ? ? ? ? ? ? ? <td><button type="button" class="btn btn-default glyphicon glyphicon-plus" onclick="addRow(this);"></button>
? ? ? ? ? ? ? ? ? <button type="button" class="btn btn-default glyphicon glyphicon-trash" onclick="delRow(this);"></button>
? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? </tr>
此時,如果直接在tr外層套上div,使用$(obj).html(),拿到的,是不含tr,td標(biāo)簽的。那么,如何能正常的拿到呢?
在tr外層加上table標(biāo)簽即可。tr標(biāo)簽必須在table標(biāo)簽內(nèi)部才有意義。另外,如果想要tr標(biāo)簽的內(nèi)容,還需要$(obj tbody).html()加上tbody