HTML DOM Source 对象

Source 对象

Source 对象表示 HTML <source> 元素。

访问 Source 对象

您可以使用 getElementById() 访问 <source> 元素:

var x = document.getElementById("mySource");

亲自试一试

创建 Source 对象

您可以使用 document.createElement() 创建 <source> 元素:

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

亲自试一试

Source 对象属性

属性 描述
media 设置或返回 <source> 元素中 media 属性的值。
src 设置或返回 <source> 元素中 src 属性的值。
type 设置或返回 <source> 元素中 type 属性的值。

标准属性和事件

Source 对象支持标准属性事件