Trying to use the snippet at Kotlin
site under HTML Builder
tap, so I wrote the below:
val tbl = createHTML().table {
for ((num, string) in data) {
tr {
td { +"$num" }
td { +string }
}
}
}
document.getElementById("container")!!.appendChild(tbl)
but the IDE is underlying the tbl
with error as below:
What mistake I;m doing here?
createHtml()
produces a String, which cannot be passed toappendChild()
. You should instead usewhich produces an HTMLElement (which is a Node) or simply skip the variable.
createHTML().xxx
is best used with serverKtor.io
where you create something like:Then send it to the browser using: