Document embeds Collection - Javascript DOM

Javascript examples for DOM:Document embeds

Description

The embeds collection returns a collection of all <embeds> elements sorted as they appear in the HTML code.

Properties

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

Methods

MethodDescription
[index] <embed> element with the specified index (starts at 0).
item(index) <embed> element with the specified index (starts at 0).
namedItem(id) <embed> element with the specified id.

Return Value:

An HTMLCollection Object, representing all <embed> elements in the document.

The following code shows how to Find out how many <embed> elements there are in the document:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<embed src="helloworld.swf">
<embed src="helloworld.swf">

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

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

<script>
function myFunction() {// w w w  . ja va 2s.  co m
    var x = document.embeds.length;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials