Fix DOM manipulation to avoid deprecated functions in Sudoku solver example.

This commit is contained in:
constraintAutomaton
2025-04-08 20:13:02 +02:00
parent 8c348a7160
commit 024c498bee

View File

@@ -266,17 +266,24 @@ Then a `pkg` directory will be created, containing everything you need for a web
} }
// Output results // Output results
document.write(`<p>Sudoku solver returns:</p>`); const solutionDiv = document.querySelector("#soduku-solution");
for (const solution of formattedSolutions) { for (const solution of formattedSolutions) {
document.write(`<pre>${solution}</pre>`); const newPre = document.createElement("pre");
newPre.textContent = solution;
solutionDiv.appendChild(newPre);
} }
</script> </script>
</head> </head>
<body></body> <body>
<p>Sudoku solver returns:</p>
<div id="soduku-solution">
</div>
</body>
</html> </html>
``` ```
Then you can serve it with your favorite http server like `python -m http.server` or `npx serve`, and access the page with your browser. Then you can serve it with your favorite http server like `python -m http.server` or `npx serve`, and access the page with your browser.