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.
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
});
}
function init() {
- for (var e of document.getElementsByTagName('input')) {
+ for (var e of document.querySelectorAll('#pixels input')) {
e.onchange = update_glyph;
}
update_glyph();