jQuery选择列表删除所有选项 [英] jQuery select list removes all options
本文介绍了jQuery选择列表删除所有选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有< select>
列表,其中已填充了多个选项,但想要删除这些选项以重新开始。
I have a <select>
list, which has been populated with several options, but want to remove those options to start again.
我正在使用jQuery并尝试过以下方法:
I am using jQuery and have tried the following:
$("#selectId").length = 0;
但这似乎没有效果。
我的部分问题是我使用Firebug来调试JavaScript,但是调试器没有在断点处中断,所以我看不出发生了什么。如果JavaScript在我的HTML文件的< head>
中,它会不会中断?
Part of my problem is that I am using Firebug to debug the JavaScript, but the debugger does not break at the breakpoint, so I cannot see what is going on. Should it break when the JavaScript is within the <head>
of my HTML file?
推荐答案
这样做:
$('#selectId').html('');
这篇关于jQuery选择列表删除所有选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文