
<!-- index.html -->
<body>
<div>
{% for chat in chats %}
<div>{{ chat.contents }}</div>
<button
onClick=getId(chat.id) ❌
>
print this chat_id out
</button>
{% endfor %}
</div>
...
<script>
function getId(id){
console.log(id)
}
</script>
</body>
chat.id in the event properties does not work.
chat.id in HTMLButtonElement as the Error says.<!-- index.html -->
<body>
<div>
{% for chat in chats %}
<div>{{ chat.contents }}</div>
<button
id={{chat.id}} ✅
onClick=getId(id) ✅
>
print this chat_id out
</button>
{% endfor %}
</div>
...
<script>
function getId(id){
console.log(id)
}
</script>
</body>
{{chat.id}} obratined by Jinja Loop into id, you have to put id in the event property. <button
id=getChatIdBtn
name={{chat.id}} ❌
onClick=getId(name) ❌
>
you can get nothing.

if you write on right element.
🙋♂️ 타란~
