I am dynamically adding a "lobby" to my table like so:
_rooms.forEach(room => {
const tr = document.createElement('tr')
tr.innerHTML = `
<th scope="row">${room.RoomName}</th>
<td>${room.UsersInRoom.length}</td>
<td>
<form>
<input class="btn btn-primary btn-sm btn-block" type="button" id="join" value="${room.RoomName}" />
</form>
</td>`
document.getElementById('room-list').appendChild(tr)
})
But I want to be able to add an onclick
event to the input type button.
How can I achieve that?