jQuery删除select中(所有)的option的方法

admin 阅读:111 2024-03-03

之前我们介绍过通过jQuery动态向select中添加option的方法,那么怎么通过jQuery动态删除select中的option呢?其实方法很简单。

jQuery删除select中的所有option:


$("#select_id").empty();

jQuery删除select中指定的option:


$("#select_id option:last").remove();  //删除Select中最后一个option
$("#select_id option[index='0']").remove();  //删除Select中第一个option
$("#select_id option[value='a']").remove();  //删除Select中Value='a'的Option
声明

1、部分文章来源于网络,仅作为参考。
2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!