jquery如何删除td列

使用jquery删除td列的方法:1.新建html项目,引入jquery;2.创建table表格,3.为表格td列设置id属性;4.添加button按钮,绑定onclick点击事件;5.通过id属性获取对象,使用remove()方法删除td列;

具体步骤如下:

1.首先,新建一个html项目,并在项目中引入jquery;

<script type="text/javascript" src="/static/jquery-2.1.4.min.js"></script>


2.引入jquery后,在项目中创建一个table表格;

<table>

<tr>

<td></td>

<td></td>

</tr>

<tr>

<td></td>

<td></td>

</tr>

</table>

3.table表格创建好后,为表格的td列设置id属性;

<table>

<tr>

<td id="nav"></td>

<td id="nav"></td>

</tr>

<tr>

<td id="nav"></td>

<td id="nav"></td>

</tr>

</table>

4.id属性设置好后,添加一个button按钮,并绑定onclick点击事件,用于点击删除td列;

<button omClick="set()"></button>


5.最后,按钮添加好后,在点击事件中通过id属性获取td对象,在使用remove()方法即可删除td列;

function set(){

$('#nav').remove();

}


Both comments and pings are currently closed.

Comments are closed.

Powered by KingAbc | 粤ICP备16106647号-2 | Loading Time‌ 0.407