HTMLSourceElement: src 屬性
HTMLSourceElement 介面的 src 屬性是一個字串,用於指定作為元素媒體資源的 URL。
它反映了巢狀在 <audio> 或 <video> 元素中的 <source> 元素的 src 屬性。當巢狀在 <picture> 元素中時,它沒有意義,會被忽略。
值
字串;用於元素中的源資源的 URL。
示例
html
<source
id="el"
src="large.webp"
type="video/webp"
media="screen and (600px <= width <= 800px)" />
js
const el = document.getElementById("el");
console.log(el.src); // Output: "large.webp"
el.src = "medium.webp"; // Updates the src value
規範
| 規範 |
|---|
| HTML # dom-source-src |
瀏覽器相容性
載入中…