zoukankan      html  css  js  c++  java
  • jquery checkbox 实现单选

    最近在用javascript的时候发现网上实现checkbox单选的代码都已经过时了。

    用着几年前的代码发现根本不行了 原因是jquery api已经更改

    http://api.jquery.com/prop/

    这里是新的代码

     $(function(){
            $(":checkbox").each(function(){
                $(this).click(function () {
                    if ($(this).is(":checked")) {
                    //$('#cb').prop('checked') 一样的效果 $(
    ":checkbox").each(function () { $(this).prop("checked", false); }); $(this).prop("checked", true); } }); }); });

    希望大家不要在这个上面浪费时间。

  • 相关阅读:
    requests模块
    爬虫基础
    forms组件
    分页器组件
    cookie与session组件
    Auth模块
    中间件组件
    git
    Ajax
    《Java程序设计》实验二 实验报告
  • 原文地址:https://www.cnblogs.com/he-yuan/p/3945644.html
Copyright © 2011-2022 走看看