JSFiddle - React, Tailwind, and code Playground
by zhang li
HTML
<a href="###">加载</a>
<select>
</select>
<a href="###">加载</a>
<select>
</select>
<a href="###">加载</a>
<select>
</select>
<a href="###">加载</a>
<select>
</select>
<a href="###">加载</a>
<select>
</select>
<a href="###">加载</a>
<select>
</select>
JavaScript
$(function(){
var option = [
{
value : '',
text : '--请选择--'
},
{
value : '1',
text : 'java'
},
{
value : '2',
text : '.net'
},
{
value : '3',
text : 'python'
}
];
$('a').click(function(){
var t = $(this).next();
if(t.val()!=null){
t.empty();
}
var tar = {};
$('select option:selected').each(function(){
if($(this).val() != '')
tar[$(this).val()] = 1;
});
var newoption = [];
$.each(option,function(i,val){
if(!tar[val.value]){
newoption.push(val);
}
});
$.each(newoption,function(i,val){
$('<option value="'+val.value+'">'+val.text+'</option>').appendTo(t);
});
});
})