JQuery 基础:11.RadioButton操作

1.取得选中值

$("input[name=gender]:checked").val()

2.设置选中值

$("input[name=gender]").val(["女"]);

3.checkbox全选、不选、反选

    //全选

            $("#all").click(function () {

                $(":checkbox").attr("checked", true);

            });

    //全不选

            $("#notxuan").click(function () {

                $("#d1 :checkbox").attr("checked", false);

            });

    //反选

            $("#fanxuan").click(function () {

                $("#d1 :checkbox").each(function () {

                   $(this).attr("checked",!$(this).attr("checked"))

                });

            });

posted @ 2012-05-23 22:49  Xyang  阅读(487)  评论(0编辑  收藏  举报
hi