Jquery遍历select option和添加移除option详解

function changeShipMethod(shipping){
var len = $("select[name=ISHIPTYPE] option").length
if(shipping.value != "CA"){
$("select[name=ISHIPTYPE] option").each(function(){
if($(this).val() == 111){
$(this).remove();
}
});
}else{
$("<option value='111'>UPS Ground</option>").appendTo($("select[name=ISHIPTYPE]"));
}
}

转自:http://www.csdnjava.com/forum.php?mod=viewthread&tid=1208

你可能感兴趣的:(jquery)