你应该只能够使用:
$lstAccountType.change(function() {
$lstAccountType.find("option[value='"+$lstAccountType.val()+"']").remove();
});
我没有测试过这一点,但一展身手,让我知道,如果它是任何好还是不好?
编辑
如果你只是想删除的第一个选项,每次你可以尝试:
$lstAccountType.change(function() {
if ($lstAccountType.find("option:first").attr("value") == $lstAccountType.val()) {
$lstAccountType.find("option[value='"+$lstAccountType.val()+"']").remove();
}
});
它需要一定的整理,但希望这可以帮助。
编辑
如果你想删除只有一次,你可以做第一个选项:
var first_option_removed = false;
$lstAccountType.change(function() {
if (!first_option_removed) {
if ($lstAccountType.find("option:first").attr("value") == $lstAccountType.val()) {
$lstAccountType.find("option[value='"+$lstAccountType.val()+"']").remove();
first_option_removed = true;
}
}
});
这一个为我工作。不是其他的($(“#list [value ='elementid']”)。remove());谢谢 –