应用场景——双盒选择器

两个select可能会出现重复的情况

排除重复代码如下:

/**
* 删除$fromGroup中与$toGroup重复的option
* @param $fromGroup = $('#' + fromGroup + ' option:selected')
* @param $toGroup = $('#' + toGroup + ' option')
*/
function filterRepeat($fromGroup, $toGroup) {
//方法一:
/*var repeatItems = $.grep($fromGroup, function(v){
// if the item does not exist return true which includes it in the new array
return $toGroup.filter("option[value='" + $(v).val() + "']").length != 0;
});*/
//方法二:
var repeatItems = $fromGroup.filter(function(index){
return $toGroup.filter("option[value='" + $(this).val() + "']").length != 0;
});
$(repeatItems).remove();
}

jquery 排除重复的更多相关文章

  1. jquery 实现重复点击一个元素时不重复执行效果

    jquery 实现重复点击一个元素时不重复执行效果 这需要用到jquery的stop方法 实例 停止当前正在运行的动画: $("#stop").click(function(){ ...

  2. SQL排除重复结果只取字段最大值

    如何用SQL排除重复结果只取字段最大值的记录?要求得到的结果(即是PID相同的记录只取ID值最大的那一条). select * from [Sheet1$] a from [Sheet1$] wher ...

  3. jquery事件重复绑定

    本文实例分析了jQuery防止重复绑定事件的解决方法.分享给大家供大家参考,具体如下: 一.问题: 今天发现jQuery一个对象的事件可以重复绑定多次,当事件触发的时候会引起代码多遍执行. 下面是一个 ...

  4. 77. Combinations (java 求C(n,k)的组合,排除重复元素)

    题目: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. 解析:同求全 ...

  5. sql2008百万级数据排除重复信息

    --高性能排除重复select userid from table where userid in ( select userid from ( select userid, row_number() ...

  6. ASP.NET的SEO:使用.ashx文件——排除重复内容

    本系列目录 不同的链接指向的页面如果具有大量相同的内容,这种现象就会被称为"重复内容",如果一个网站的重复内容很多,搜索引擎就会认为这个网站的价值不高.所以我们应尽量避免各种重复内 ...

  7. jquery事件重复绑定的几种解决方法 (二)

    防止事件重复绑定共有4种方法: bind().unbind()方法 live().die()方法 off().on()方法 one()方法 一.bind().unbind()方法 bind();绑定事 ...

  8. 2016.8.11 DataTable合并及排除重复方法

    合并: DataTable pros=xxx; DataTable pstar=yyy; //将两张DataTable合成一张 foreach (DataRow dr in pstar.Rows) { ...

  9. jquery事件重复绑定的几种解决方法

    防止事件重复绑定共有4种方法: bind().unbind()方法 live().die()方法 off().on()方法 one()方法 一.bind().unbind()方法 bind();绑定事 ...

随机推荐

  1. mongodb pymongo.errors.CursorNotFound: Cursor not found, cursor id: 82792803897

    默认 mongo server维护连接的时间窗口是十分钟 默认 单次从 server获取数据是101条或者 大于1M小于16M的数据 所以默认情况下,如果10分钟内未能处理完数据,则抛出该异常. 解决 ...

  2. (LeetCode 49)Anagrams

    Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be ...

  3. ! Undefined control sequence. \CJK@XXX ...endcsname {`#2}{`#3}\CJK@ignorespaces \fi l.43 \end{document}

    错误的原因是:你的文本内容超过了一页,需要增加新的一页. 解决问题的方法就是在\end{CJK}或者\end{CJK*}之前加入\newpage,\clearpage或者\cleardoublepag ...

  4. laravel 安装环境安了三天!!

    各种报错,各种升级,各种重装,重启!! 记录一下一些错误吧,,, 错误太复杂,,,, 原因:版本问题!.CPU虚拟化问题.win10问题.软件兼容性问题.还有就是各种不细心啥的         分割线 ...

  5. ant design pro (九)引入外部模块

    一.概述 原文地址:https://pro.ant.design/docs/import-cn 除了 antd 组件以及脚手架内置的业务组件,有时我们还需要引入其他外部模块,这里以引入富文本组件 re ...

  6. javascript&jquery 判断滚动到页面底部

      js 判断滚动到页面底部 CreateTime--2018年4月14日10:13:07 Author:Marydon 1.使用场景: 滚动到屏幕底部,触发加载分页数据请求(qq空间,手机端) 2. ...

  7. CentOS连接网络注意事项

    连接网络,系统中这两个服务需要启动 可以看到右上角网络连接成功了

  8. JS 校验,检测,验证,判断函数集合

    http://jc-dreaming.iteye.com/blog/754690 /**  *判断对象是否为空 *Check whether string s is empty.  */  funct ...

  9. .net core json序列化首字符小写和日期格式处理

    打开Startup.cs文件,在ConfigureServices方法中添加如下代码 public void ConfigureServices(IServiceCollection services ...

  10. express@4.0.*

    $ sudo npm install -g express the installation goes fine. But when I try to create a project with ex ...