X

Example 3

package okoko
import kotlin.browser.document
import kotlin.browser.window
external fun jQuery(selector: Any?): Unit

fun log() {
    println("log from Kotlin for JavaScript!")
}

fun jtext(selector:Any,txt:Any) {
    jQuery(selector).asDynamic().text(txt)
}

fun boombayah() {
    jQuery(document).asDynamic().ready({
        jQuery("p").asDynamic().click( { jtext("p","Thank You, Sir!") })
        jtext("p","If you click on me, You will be mesmerized.")
    })
}

fun main(args: Array<String>) {
    println("Welcome to Kotlin for JavaScript!")
}
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cloud.ibinti.com/file/ko4js/ko4js.core.js"></script>
<script>ko4js.okoko.boombayah()</script>
</head>
<body>

<p>If you click on me, You will be blessed.</p>

</body>
</html>