Javascript examples for DOM HTML Element:Figure
You can create a <figure> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create a FIGURE element containing an IMG element</button><br><br> <script> function myFunction() {// w w w .ja va 2 s . com var x = document.createElement("FIGURE"); x.setAttribute("id", "myFigure"); document.body.appendChild(x); var y = document.createElement("IMG"); y.setAttribute("src", "http://java2s.com/resources/a.png"); y.setAttribute("width", "300"); y.setAttribute("width", "200"); y.setAttribute("alt", "an image"); x.appendChild(y); } </script> </body> </html>