Latest web development tutorials

HTML DOM Source Object

Source Object

Source object is new in HTML5.

Source object represents an HTML <source> element.

Source Object Access

You can use getElementById () to access the <source> element:

var x = document.getElementById("mySource"); 尝试一下

Creating Source Objects

You can use the document.createElement () method to create a <source> element:

var x = document.createElement("SOURCE"); 尝试一下

Source Object Properties

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

Standard properties and events

Source object also supports the standard attributes and events .


related articles

HTML Tutorial: the HTML5 Connections Video (Video)

HTML Tutorial: the HTML5 Audio (Audio)

HTML Reference Manual: HTML <Source> tag