HTML | DOM embeds Collection

The DOM embeds collection property is used to return the collection of all embedded element. The elements in the collection are sorted that appear in the source code. This property is used for read-only.

Syntax:

document.embeds

Property: This property contains a value length which returns the number of elements in the document.



Methods: The DOM embeds collection contains three methods which are given below:

  • [index]: It is used to return the element of selected index. The index value starts with 0. It returns NULL if the index value is out of range.
  • item(index): It is used to return the <embed> element of selected index. The index value starts with 0. It returns NULL if the index value is out of range.
  • namedItem(id): It is used to returns the <embed> element from the collection with given id attribute. It returns NULL if the id is not valid.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>DOM embeds Collection</title>
        <style>
            h1 {
                color:green;
                font-weight:bold;
            }
            body {
                text-align:center;
            }
        </style>
    </head>
    <body>
        <h1>GeeksForGeeks</h1>
        <h2>DOM embeds Collection</h2>
        <embed src="geeksforgeeks.swf">
        <embed src="geeksforgeeks.swf">
        <button onclick="geeks()">Submit</button>
        <p id="sudo"></p>
        <script>
            function geeks() {
                var x = document.embeds.length;
                document.getElementById("sudo").innerHTML = 
                        "Number of embed Element is:" + x;
            }
        </script>
    </body>
</html>                                

chevron_right


Output:

Supported Browsers: The browser supported by DOM embeds Collection property are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.