Javascript DOM HTML document embeds Collection

Introduction

Find out how many <embed> elements there are in the document:

var x = document.embeds.length;

Click the button to display the number of embed elements there are in this document.

View in separate window

<!DOCTYPE html>
<html>
<body>

<embed src="video.mp4">
<embed src="video.mp4">

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/* ww  w . j  av a  2s  .co  m*/
  var x = document.embeds.length;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The embeds collection returns a collection of all <embeds> elements in the document.

The elements in the collection are sorted as they appear in the source code.

Properties

Property Description
length Returns the number of <embed> elements in the collection.

This property is read-only

Methods

Method
Description
[index]

Get the <embed> element from the collection with the specified index starting at 0.
Returns null if the index number is out of range
item(index)

Returns <embed> element from the collection with the by index starting at 0.
Returns null if the index number is out of range
namedItem(id)

Returns the <embed> element from the collection with the specified id.
Returns null if the id does not exist



PreviousNext

Related