Button nameプロパティ

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

定義と使用方法

name プロパティは、ボタンの name 属性値を設定または返します。

name プロパティはボタンの名前を指定し、フォーム送信後にデータをバックエンドの動的言語で参照する場合や、JavaScript 内の要素を参照する場合によく使用されます。/p>

構文

buttonObject.name=name


ブラウザサポート

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


例

例

ボタンの name 属性値を返します:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
</head>
<body>

<button id="button1" name="button1">点我!</button>
<p>ボタンの名前:
<script>
document.write(document.getElementById("button1").name);
</script></p>

</body>
</html>

試してみる »


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