Suppose you are using jq from the standard library, and above all, jq from the standard library is deprecated.
Then consider the definition of a click handler:
public fun click(handler: (MouseClickEvent) -> Unit): JQuery
As you can see, it in your case MouseClickEvent . But MouseClickEvent and MouseEvent does not contain target .
You can write your own bindings for jquery:
import jquery.MouseClickEvent import jquery.MouseEvent @JsName("$") public external fun jq(selector: String): JQuery public external class JQuery() { public fun click(handler: (ExtendedMouseClickEvent) -> Unit): JQuery } public external class ExtendedMouseClickEvent() : MouseEvent { public val target: JQuery public val which: Int } fun main(args: Array<String>) { jq("#element").click { console.log(it.target) } }
In addition, you can convert existing definitions for TypeScript to kotlin.
jQuery: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/jquery
ts2kt: https://github.com/Kotlin/ts2kt
source share