Skip to content

Commit d55ab22

Browse files
gzm0sjrd
authored andcommitted
Step 3: Using the DOM
1 parent 0ec7ca1 commit d55ab22

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

build.sbt

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ scalaVersion := "2.13.6"
55

66
// This is an application with a main method
77
scalaJSUseMainModuleInitializer := true
8+
9+
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.2.0"
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
package tutorial.webapp
22

3+
import org.scalajs.dom
4+
import org.scalajs.dom.document
5+
36
object TutorialApp {
47
def main(args: Array[String]): Unit = {
5-
println("Hello world!")
8+
appendPar(document.body, "Hello World")
9+
}
10+
11+
def appendPar(targetNode: dom.Node, text: String): Unit = {
12+
val parNode = document.createElement("p")
13+
parNode.textContent = text
14+
targetNode.appendChild(parNode)
615
}
716
}

0 commit comments

Comments
 (0)