我有这种HTML
<select id="SelectedCulture" name="SelectedCulture">
<option></option>
<option>en-US</option>
</select>
我在Jquery中需要删除的是空的吗?
答案 0 :(得分:6)
答案 1 :(得分:1)
去吧:
$("#SelectedCulture > option").each(function(){
if($(this).text().length==0)
$(this).remove();
});
答案 2 :(得分:1)
$("option").each(function() {
var text= $(this).text();
if(text== '') { // or anything else you want to remove...
$(this).remove();
}
});
这将删除
中的空元素<强> [编辑] 强>
仍然建议更喜欢Anoop Joshi的回答