js控制input type=checkbox 的勾选

时间:2023-03-09 16:46:47
js控制input  type=checkbox  的勾选
<script type="text/javascript">
    $(function () {
        //双击表格弹出窗口
        //为jQuery类添加类方法,可以理解为添加静态方法
        $.extend({
                'getInfo': function (id) {
                    //pdialog:应该是DWZ的方法
                    $.pdialog.open("__URL__/showinfo/id/" + id, 'dialog', '查看会员信息', {maxable:false,mask:true,width:500,height:300});
                },
                'delete_this': function(obj){
                    var _this = obj;
                    var input_obj = $(_this).find("input[type='checkbox']");
                    if($(input_obj).attr('checked') == 'checked'){ //如果已经勾选.则取消勾选
                        $(input_obj).attr('checked',null)
                    }else{
                        $(input_obj).attr('checked','checked')
                    }
                }  
            });
    });
</script>
<volist id="vo" name="list">   <!-- TP的循环 -->
                <tr target="sid_user" rel="{$vo['id']}" ondblclick="$.getInfo({$vo['id']});" onclick="$.delete_this(this);" aaa="{$vo['id']}"> <!-- 绑定函数$.delete_this -->
                    <td><input type="checkbox" name="id" value="{$vo['id']}" /></td>
                    <td>{$vo['id']}</td>
                    <td>{$vo['username']}</td>
                    <td>{$vo['email']}</td>
                    <td>{$vo['user_money']}</td>
                    <td>{$vo['reg_time']}</td>
                    <td>{$vo['qq']}</td>
                    <td><if condition="$vo['status'] eq 1">正常<else />禁止</if></td>
                </tr>
            </volist>