1let div = document.createElement("div");
2div.classList.add("yourClass");
3div.setAttribute("onclick", "yourFunction()");
4div.setAttribute("onmouseover", "hoverOn()")
5div.style.background = "yourColor";
6let divInDiv = document.createElement("div");
7divInDiv.classList.add("yourClass");
8div.appendChild(divInDiv);
1// in your string you can call your variable like ${myVar}. eg:
2var myVar = "blue";
3console.log("The sky is " + myVar + ".");
4// Output: "The sky is blue."
1<html>
2 <head>
3 <title>JavaScript Strings</title>
4 </head>
5 <body>
6 <script>
7 var re = "java";
8 var str = "Learn java";
9 if ( str.search(re) == -1 ){
10 document.write("Not found!" );
11 } else {
12 document.write("Found!" );
13 }
14 </script>
15 </body>
16</html>