Skip to content

Commit 2983284

Browse files
added check so that the inputs are automatically focused only when the created input is not the first on the page - fixes the problem of the page jumping to the example when embedded, when it first loads
1 parent 4b024b6 commit 2983284

File tree

1 file changed

+6
-4
lines changed
  • javascript/introduction-to-js-1/variables

1 file changed

+6
-4
lines changed

javascript/introduction-to-js-1/variables/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454
</style>
5555
</head>
5656
<body>
57-
58-
<script>
57+
<script>
5958
var geval = eval;
6059
function createInput() {
6160
var inputDiv = document.createElement('div');
@@ -68,6 +67,10 @@
6867
inputDiv.appendChild(inputForm);
6968
document.body.appendChild(inputDiv);
7069

70+
if(document.querySelectorAll('div').length > 1) {
71+
inputForm.focus();
72+
}
73+
7174
inputForm.addEventListener('change', executeCode);
7275
}
7376

@@ -91,10 +94,9 @@
9194

9295
createInput()
9396
}
94-
97+
9598
createInput();
9699

97100
</script>
98-
99101
</body>
100102
</html>

0 commit comments

Comments
 (0)