HTML DOM source object

The HTML DOM source object is associated with the HTML element. We can create and access source element using the createElement() and getElementById() method respectively.

Syntax

Following is the syntax for ?

Creating a source object ?

var p= document.createElement("SOURCE");

Example

Let us look at an example for the source object ?



Source object example

Add a audio source for the above element by clicking the below element.

Output

This will produce the following output ?

On clicking the CREATE button ?

Click "CREATE" ?

Updated on: 2026-03-11T22:50:45+05:30

146 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements