for循环出来的button怎么增加点击过后的样式---麻烦大佬们

for循环出来的button怎么增加点击过后的样式---麻烦大佬们

$.ajax({
                        url: url + '/groupingForType/',
                        data: {
                            groupNum: groupNum,
                            type: type
                        },
                        async: false,
                        dataType: 'json', //服务器返回json格式数据
                        type: 'post', //HTTP请求类型
                        timeout: 10000, //超时时间设置为10秒;
                        success: function(data) {
                            console.log(data);
                            for (var i = 1; i < parseInt(data.maxGroup) + 1; i++) {
                                button +=
                                    `<div class="col-md-2 top"><button type="button" onclick="getGroup(${i})" style="width:80%"  id="btntwo" class="btn btn-danger">第${i}组</button></div>`

                            }

                            document.getElementById("typeNum").innerHTML = button

                        },
                        error: function(xhr, type, errorThrown) {
                            console.log("报错")
                        }
                    });

在button绑定的click方法中通过id获取到节点,然后修改样式
还有你这代码有bug为什么循环渲染的button的id都相同的,id要唯一的