From: Ben Harris Date: Sat, 4 Oct 2025 21:27:37 +0000 (+0100) Subject: webstead: prefer querySelector[All] over getElement* X-Git-Tag: bedstead-3.261~51 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=c99994e91d4e11e16e773c4225157f97c64a831f;p=bedstead.git webstead: prefer querySelector[All] over getElement* It's a bit shorter, a bit more general, and allows me to properly query only input elements that are children of the table of pixels. --- diff --git a/webstead.xhtml b/webstead.xhtml index c3bb0c1..919d17b 100644 --- a/webstead.xhtml +++ b/webstead.xhtml @@ -46,9 +46,9 @@ function update_glyph() { var args = []; var cstr = ""; - for (var row of document.getElementById("pixels").rows) { + for (var row of document.querySelector('#pixels').rows) { var arg = 0; - for (var pixel of row.getElementsByTagName('input')) { + for (var pixel of row.querySelectorAll('input')) { arg *= 2; if (pixel.checked) { arg += 1 @@ -75,7 +75,7 @@ }); } function init() { - for (var e of document.getElementsByTagName('input')) { + for (var e of document.querySelectorAll('#pixels input')) { e.onchange = update_glyph; } update_glyph();