Manipulating the DOM via Kotlin

Let's walk through this concept of generating bindings to a third-party library to modify our web page using jQuery through our Kotlin code. To do this we're going to need to find TypeScript bindings for jQuery, convert those to Kotlin with ts2kt, and then use those bindings to manipulate our page from Kotlin.

By following these steps, we'll be able to add HTML elements to our web page programmatically from our Kotlin code:

  1. First, install the ts2kt tool using the following npm command: npm -g install ts2kt.
  2. Then, from the root directory of our project, install jQuery on your machine using npm install jquery. We'll need to test our project in our local development environment. This should result in a node_modules ...

Get Mastering Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.