jquery 单选框 radio是否选择问题

业务需求是当用户勾选中的时候删除数据,取消勾选的时候数据取消

//单选事件,获取到每行数据ID
                            $('.checkItem').change(function(){   // checkItem是给radio添加的class类
                                var index=$(this).parent().parent().index()
                                if($(this).attr('checked')){//如果被选中
                                    $(this).parent().parent().css('background','#dff0d8')
                                    $('.idBox').text(data.data[index].id) //如果被勾选,就把值存在一个div里面
                                }else{//如果没被选中
                                    $('.idBox').text('')  //如果取消勾选就把值清空
                                    $(this).parent().parent().css('background','')
                                }
                            })

 

posted @ 2019-05-07 20:22  尼古拉斯-富贵  阅读(193)  评论(0编辑  收藏  举报