Javascript examples for DOM HTML Element:Legend
You can create a <legend> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <fieldset id="myFieldset"> Name: <input type="text"> </fieldset><br> <button onclick="myFunction()">create a LEGEND element with some text</button> <script> function myFunction() {/*w w w . j a v a2 s . co m*/ var x = document.createElement("LEGEND"); var t = document.createTextNode("Personalia:"); x.appendChild(t); document.getElementById("myFieldset").appendChild(x); } </script> </body> </html>