Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

label

label
Type: string
The label that will appear on the element. If this is left out, no text appears.
label 在元素上显示。如果左侧出界,则不显示任何文字。

See also

Examples in JavaScript

<label value="Whaw" id="the-big-label" command="the-big-button"/>
<button id="the-big-button" label="Click me"
	oncommand="alert(document.getElementById('the-big-label').value)"/>

<label id="myLabel" value="My label"/>
<button label="Click me" 
	oncommand="document.getElementById('myLabel').setAttribute('value','Value changed');" />

<checkbox label="my Checkbox" id="myCheckboX"/>
<button label="Another click" 
	oncommand="document.getElementById('myCheckboX').setAttribute('label','Still not checked');"/>
<button label="Show label of checkbox" 
	oncommand="alert( document.getElementById('myCheckboX').getAttribute('label') )"/>

文档标签和贡献者

 此页面的贡献者: ziyunfei, Mhoudg, Gamlty
 最后编辑者: ziyunfei,