Get Figure Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Figure

Introduction

The Figure object represents an HTML <figure> element.

You can access a <figure> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<figure id="myFigure">
  <img src="http://java2s.com/resources/a.png" alt="alt message" width="300" height="200">
</figure>/*w w w  .j av a2  s.  c o m*/

<button onclick="myFunction()">get the id of the FIGURE element</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myFigure").id;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials