问问题
87 次
3 回答
1
function AddCountry(element) {
var oldSelect = jQuery("select[name='investor-country[]']").last();
var newSelect = jQuery(oldSelect).clone();
// Remove previously selected option
var selected = oldSelect.val();
newSelect.find("option[value="+selected+"]").remove();
jQuery(element).before(newSelect);
}
于 2013-07-05T06:55:10.043 回答
0
删除所选选项的另一种方法:
newSelect.find('option').eq(oldSelect[0].selectedIndex).remove();
于 2013-07-05T07:01:52.630 回答
0
尝试这个:
//get the selected value
var val = $("select[name='investor-country[]']").val();
//get the selected option
var option = $("option[value="+val+"]");
//append the selected country somewhere
$('#selected').append('<span>'+option.text()+'</span> ');
//remove the selected option
option.remove();
于 2013-07-05T07:04:55.060 回答