Input Button typeプロパティ

Button 对象参考手册Button オブジェクト

定義と使い方

type プロパティはフォーム要素のタイプを返します。

Button オブジェクトのタイプは常に "button" です。

構文

buttonObject.type


ブラウザサポート

Internet ExplorerFirefoxOperaGoogle ChromeSafari

すべての主要ブラウザが type プロパティをサポートしています。


例

例

次の例では、ボタンのフォーム要素のタイプを返します。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
    var x=document.getElementById("button1").type;
    alert(x);
}
</script>
</head>
<body>

<form>
<input type="button" onclick="displayResult()" value="显示按钮类型" id="button1">
</form>

</body>
</html>

試してみる »


Button 对象参考手册Button オブジェクト その他の拡張