HTMLSourceElement: src property
The src
property of the HTMLSourceElement
interface is a string indicating the URL of a media resource to use as the source for the element.
It reflects the src
attribute of the
element nested in an or
element. It has no meaning and is ignored when it is nested in a
element.
Value
A string; the URL of a source resource to use in the element.
Examples
html
js
const el = document.getElementById("el");
console.log(el.src); // Output: "large.webp"
el.src = "medium.webp"; // Updates the src value
Specifications
Specification |
---|
HTML # dom-source-src |