//全选产品
$('#checkAll').click(function() {
$(this).prop('checked',!$(this).prop('checked'));
if($(this).prop('checked')) {
$(this).prop('checked',false);
$('#getProduct input').each(function(index,item) {
$(item).prop('checked',false)
})
}else {
$(this).prop('checked',true);
$('#getProduct input').each(function(index,item) {
$(item).prop('checked',true)
});
};
});

//二分查找
function binarySearch(arr,target) {
var l = 0,r = arr.length-1;
while(l <= r) {
var mid = (l+r)/2;
if(arr[mid] == target) {
return mid
}else if(arr[mid] < target) {
l = mid+1
}else {
r = mid-1
}
};
return -1;
}
//多选产品
$('#getProduct input').each(function(index,item) {
$(item).click(function() {
var count = 0;
if (!$(this).prop("checked")) {
$(this).prop("checked", false);
} else {
$(this).prop("checked", true);
};
$('#getProduct input').each(function(index,item) {
if($(item).prop('checked')) {
count ++;
}else {
count --;
};
});
if(count == $('#getProduct input').length) {
$('#checkAll').prop('checked',true)
}else {
$('#checkAll').prop('checked',false)
};
})
})

其中#checkAll是全选按钮的id,#getProduct input是tbody中的所有类型为checkbox的input。

jquery的全选和多选操作的更多相关文章

  1. jquery checkbox全选,全不选,反选方法,jquery checkbox全选只能操作一次

    jquery checkbox全选,全不选,反选方法, jquery checkbox全选只能操作一次, jquery checkbox全选只有第一次成功 >>>>>&g ...

  2. jQuery实现全选、全不选、反选

    如图,需要使用jQuery实现全选.全不选.反选功能: 核心代码: 全选 $("#check_all").click(function(){ $("input:check ...

  3. 11月8日下午Jquery取属性值(复选框、下拉列表、单选按钮)、做全选按钮、JSON存储、去空格

    1.jquery取复选框的值 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "htt ...

  4. jQuery实现全选效果【转】

    这是一段用jquery实现全选的代码,主要思路如下: 1.所有的复选框都有单击事件,所有效果都是在单击事件下实现的 2.全选复选框所实现的功能与其他复选选项实现的功能不同,所有在单击事件内做一个判断, ...

  5. jquery的全选插件

    全选看起来挺简单的,要做得完美就不那么容易了. 目前,我的全选插件能做到以下6点: 1.点击全选checkbox,能将要选择的checkbox都选中.去掉全选按钮,能将所有的checkbox都不选.这 ...

  6. python: jquery实现全选 反选 取消

    引入这个jquery-1.12.4.js jquery实现全选 反选 取消 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitio ...

  7. jquery实现全选功能

    主要是模拟一些网页中的表格实现全选功能. <form> 你爱好的运动是: <input type="checkbox" id="Check" ...

  8. jquery实现全选、反选、不选

    <!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8&quo ...

  9. jquery的全选/全不选/反选以及attr添加checked属性失败的解决办法

    如下图: <head> <title></title> <style type="text/css"> div { border: ...

  10. Jquery取属性值(复选框、下拉列表、单选按钮)、做全选按钮、JSON存储、去空格

    1.jquery取复选框的值 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "htt ...

随机推荐

  1. Python发送邮件代码

    Python发送带附件的邮件代码 #coding: utf-8 import smtplib import sys import datetime from email.mime.text impor ...

  2. P2900 [USACO08MAR]土地征用Land Acquisition

    \(\color{#0066ff}{ 题目描述 }\) 约翰准备扩大他的农场,眼前他正在考虑购买N块长方形的土地.如果约翰单买一块土 地,价格就是土地的面积.但他可以选择并购一组土地,并购的价格为这些 ...

  3. 再谈hive-1.0.0与hive-1.2.1到JDBC编程忽略细节问题

    不多说,直接上干货,这个问题一直迷惑已久,今天得到亲身醒悟. 所以,建议hadoop-2.6.0.tar.gz的用户与hive-1.0.0搭配使用.当然,也可以去用高版本去覆盖它. log4j:WAR ...

  4. react 中文文档案例六 (表单)

    class Reservation extends React.Component { constructor(props) { super(props); this.state = { isGoin ...

  5. BestCoder Round #66 1001

    GTW likes math Accepts: 472      Submissions: 2140  Time Limit: 2000/1000 MS (Java/Others)  Memory L ...

  6. Java换行符

    public static final String NewLineSeparator=System.getProperty("line.separator","\n&q ...

  7. 轻量级RPC框架-motan

    https://github.com/weibocom/motan/wiki/zh_quickstart#%E7%AE%80%E5%8D%95%E8%B0%83%E7%94%A8%E7%A4%BA%E ...

  8. linux下lua运行环境安装

    1.下载安装包: [root@H0f ~]# wget  http://www.lua.org/ftp/lua-5.2.4.tar.gz    http://www.lua.org/ftp/lua-5 ...

  9. thinkPHP 全局函数

    M函数 TP的Model父类,封装的功能比较多,增删改查操作都具备.一些表,比如留言表,comment class CommentModel extends Model { } M('comment' ...

  10. TestNG的testng.xml配置概述

    TestNG提供的annotaions用来辅助定义测试类. TestNG的testng.xml配置文件用来辅助定义执行什么样的测试,即testng.xml更像是一个测试规划. testng.xml配置 ...