Javascript examples for DOM HTML Element:Legend
The Legend object represents an HTML <legend> element.
You can access a <legend> element by using getElementById():
<!DOCTYPE html> <html> <body> <fieldset> <legend id="myLegend">Personalia:</legend> Name: <input type="text"> </fieldset> <button onclick="myFunction()">get the text of the legend element</button> <p id="demo"></p> <script> function myFunction() {//from w w w . j av a2s . c o m var x = document.getElementById("myLegend").innerHTML; document.getElementById("demo").innerHTML = x; } </script> </body> </html>