我知道标题不是很描述,但我希望我能澄清我的问题:我有多个相同的选择下拉列表。现在,我不想做的是从所有其他下拉列表中删除一个选项,如果它是在其中一个中选择的。下面是一个示例:
我有ids 'a‘、'b’和'c‘的选择。所有这些文件都包含以下选项:
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>如果我现在选择了选择列表'a‘中的'1’选项,我希望用JQuery从列表'b‘和'c’中删除'1‘选项。
编辑:这基本上是我拥有的全部:http://jsfiddle.net/j91p8eo5/
有人有什么想法吗?
发布于 2014-11-25 09:18:34
那你就可以这么做
var elems = $('#a,#b,#c'); // cache the variable
elems.on('change', function(){ // attach a change handler
   elems.not(this) // remove the current element from the object
  .find('[option='+ $(this).val() +']') // find the option to be removed
  .remove(); // remove it
});https://stackoverflow.com/questions/27122642
复制相似问题