Input URL disabled 属性

定义和用法

disabled 属性设置或返回是否应禁用 URL 字段。

禁用的元素不可用且不可点击。默认情况下,禁用的元素通常在浏览器中呈现为灰色。

此属性反映 HTML disabled 属性。

另请参阅:

HTML 参考手册:Proprietà disabled dell'<input> HTML

实例

例子 1

禁用 URL 字段:

document.getElementById("myURL").disabled = true;

亲自试一试

例子 2

查明 URL 字段是否被禁用:

var x = document.getElementById("myURL").disabled;

亲自试一试

例子 3

禁用和取消禁用 URL 字段:

function disableBtn() {
  document.getElementById("myURL").disabled = true;
}
function undisableBtn() {
  document.getElementById("myURL").disabled = false;
}

亲自试一试

语法

返回 disabled 属性:

urlObject.disabled

设置 disabled 属性:

urlObject.disabled = true|false

属性值

描述
true|false

Definire se il campo URL dovrebbe essere disabilitato

  • true - Il campo URL è disabilitato
  • false - predefinito. Il campo URL non è disabilitato

Dettagli tecnici

Valore di ritorno: Valore booleano, restituisce se il campo URL è disabilitato true; altrimenti restituisce false.

Supporto browser

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supportato 10.0 Supportato Non supportato Supportato