3 ms·
It's still better than <span> or <div> though, isn't it? Which is what most people are using right now...
by DangerousPie 1y ago
It's still better than <span> or <div> though, isn't it? Which is what most people are using right now...
- c-smile 1y ago"better" in what sense? If in hypothetical semantic meaning then another old zombie <var> is better in that sense, isn't it?
- samhh 1y agoThose semantics make it more accessible for free.
- runarberg 1y agoUnlike <div> and <span>, <output> becomes part of the form and you can target it as a named form item, e.g. <form id="my-form"> <input name="number" type="number"> <output name="result"></output> </form> <script> const myForm = document.getElementById("my-form"); const inputField = document.elements.namedItem("number"); const outputField = document.elements.namedItem("result"); outputField.textContent = inputField.valueAsNumber ** 2; </script>
- runarberg 1y agoToo late to edit, but there is a mistake s/document.elements/myForm.elements/r : - const inputField = document.elements.namedItem("number"); - const outputField = document.elements.namedItem("result"); + const inputField = myForm.elements.namedItem("number"); + const outputField = myform.elements.namedItem("result");