zoukankan      html  css  js  c++  java
  • jQuery设置checkbox 为选中状态

    1设置第一个checkbox 为选中值
    $('input:checkbox:first').attr("checked",'checked');

    或者
    $('input:checkbox').eq(0).attr("checked",'true');

    2、设置最后一个checkbox为选中值
    $('input:checkbox:last').attr('checked', 'checked');

    或者
    $('input:checkbox:last').attr('checked', 'true');

    3、根据索引值设置任意一个checkbox为选中值
    $('input:checkbox).eq(索引值).attr('checked', 'true');索引值=0,1,2....

    或者
    $('input:checkbox').slice(1,2).attr('checked', 'true');

    4、选中多个checkbox同时选中第1个和第2个的checkbox
    $('input:checkbox').slice(0,2).attr('checked','true');

    5、根据Value值设置checkbox为选中值
    $("input:checkbox[value='1']").attr('checked','true');

    6、设置某一个checkbox为选中值

    选中checkbox:$(":checkbox").prop("checked", true);
    取消选中:$(":checkbox").prop("checked", false);

    参考:http://www.cnblogs.com/hs8888/archive/2016/05/23/5520511.html

  • 相关阅读:
    重视需求
    某2个人的qq对话
    公司安全提示
    需求实施心得
    项目远景
    发布系统应注意的几小点问题
    把握项目开发的节奏
    Css介绍
    调研工作的思路
    网,无处不在
  • 原文地址:https://www.cnblogs.com/weimingxin/p/7141966.html
Copyright © 2011-2022 走看看