zoukankan      html  css  js  c++  java
  • JQuery操作CheckBox和Radio

    <input type="checkbox" id="dx">多选框
    <input type="radio" name="select" value=1>单选1
    <input type="radio" name="select" value=2>单选2
    <input type="radio" name="select" value=3>单选3

    一、判断CheckBox是否选中

    var isChecked = $('#dx').is(':checked');//选中返回true,未选中返回false

    二、获取Radio的选中值

    var checkValue = $('input[name="select"]:checked').val();

    三、设置CheckBox的勾选状态

    $('#dx').attr('checked',true)

    四、设置Radio选中

    $('input[name="select"]:eq(1)').attr('checked',true);
    $('input[name="select]').eq(1).attr('checked',true);


     

  • 相关阅读:
    [bzoj4364] [IOI2014]wall砖墙
    [bzoj3064] [Tyvj 1518] CPU监控
    [bzoj3434] [WC2014]时空穿梭
    ASP.NET
    ASP.NET
    ASP.NET
    ASP.NET
    ASP.NET
    ASP.NET
    MSSQL
  • 原文地址:https://www.cnblogs.com/ecosu/p/4588079.html
Copyright © 2011-2022 走看看